Reputation: 1
This is my code:
new_final_array=[x for x in new_array]
for a in range(len(array)):
for d in range(2):
for l in range(len(new_array)):
if new_array[l][d]==array[a][1]:
print l,d
new_final_array[l][d]=array[a][0]
I created list1(new_final_array) based on list2(new_array) and if I change one element on list1 it will also change on list2. How can I make them independent?
Upvotes: 0
Views: 96
Reputation: 572
I'm not sure if I understand, but maybe copy.deepcopy
will be of some use.
import copy
new_list = copy.deepcopy(old_list)
See documentation.
Upvotes: 3
Reputation: 798536
Copy one level deeper.
new_final_array=[x[:] for x in new_array]
Upvotes: 3