I have a Python code, where I first define two lists, then I make them identical and do the same operation on them after they are identical - but the result is not the same:
test1 = [[[0],[0]]]*2
test2 = [[0]]*2
test2[0] = [[0],[0]]
test2[1] = [[0],[0]]
print 'They are identical?:',test1 == test2 # gives True
# Now that test1 == test2 do the same operation on test list 1 and 2:
test1[0][0] = 2
test2[0][0] = 2
print test1
print test2
This gives
[[2, [0]], [2, [0]]] # test1
[[2, [0]], [[0], [0]]] # test2
Can somebody explain the difference to me?