This is MWE of what I'm trying to do:
lis = []
# Initialize empty list
for i in range(2):
lis.append([[0]]*2)
# First print
print lis
# Second print
print lis[0][1][0]
# Modify item
lis[0][1][0] += 1
# Third print
print lis
The first print
returns the list as [[[0], [0]], [[0], [0]]]
which is correct, I have a first list which is composed of several lists, each one also composed of several lists (I need this nested lists for what I'm doing). The second print
returns the item in indexes 0 and 1 as 0
which is also correct. But the third print
shows me the new list as:
[[[1], [1]], [[0], [0]]]
instead of:
[[[0], [1]], [[0], [0]]]
which is what I actually aimed at. What am I doing wrong?