I wrote this code:
if __name__ == "__main__" :
lst = []
current= []
for i in range(3):
print(current)
print(lst)
lst.append(current)
print(lst)
current.append(i)
I expected it to print:
[]
[]
[[]]
[0]
[[]]
[[],0]
[0,1]
[[],0]
[[],0,[0,1]]
But instead it printed:
[]
[]
[[]]
[0]
[[0]]
[[0], [0]]
[0, 1]
[[0, 1], [0, 1]]
[[0, 1], [0, 1], [0, 1]]
I don't understand why lst
changes its members into current.