I create two lists that seems the same
x = [[]]*4
y = [[],[],[],[]]
since when I print x, y
, they give me the same output [[],[],[],[]]
. However, when I apply the same operation x[0].append((1,2)), y[0].append((1,2))
on them, they give me different result
print x >> [[(1, 2)], [(1, 2)], [(1, 2)], [(1, 2)]]
print y >> [[(1, 2)], [], [], []]
Why this happens? And how to modify x
to make sure x
and y
are exactly the same?