I'm trying to create a copy of a list and use it inside my function.
import copy
islands=[['a','b','c',],[]]
def transfer(thing):
new_islands=copy.copy(islands)
new_islands[0].remove(thing)
return new_islands
transfer('b')
print(islands)
//output ['a','c']
I have tried other methods of copying such as new_list=old_list[:]
and even creating a for loop that appends every element to an empty list, but I still can't get to separate both lists.
Sorry if this has been asked before, but I really couldn't find an answer to my problem.