I made a list of lists and then a copy of it. I tried to insert different values into the elements of each one.
list1 = [
[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1]
]
list2 = list1.copy()
for i in range(8):
list1[i].insert(0, 0)
list2[i].insert(0, 1)
But the result is both lists affected by both insertions. I know they're different objects because I printed their ID's using id(list1)
and id(list2)
, so I can't understand why this is happening.
Any help would be useful.
Thank you in advance.