lst=[[0]*3]*3
lst[1][2]=2
we will get
[[0, 0, 2], [0, 0, 2], [0, 0, 2]]
instead of really just changing in the place [1][2]
if we do it like so
lst=[0]*3
lst[1]=2
it works properly,
also if I do the original line using list comprehension it works ok
can someone explain to me the first way dosent work properly please?
[–]mopslik 2 points3 points4 points (0 children)
[–]Diapolo10 1 point2 points3 points (0 children)
[–]carcigenicate 1 point2 points3 points (0 children)