saw this snippet on the internet : why assigning by index propagates it all?

>>> a = [[1]] * 7
>>> a
[[1], [1], [1], [1], [1], [1], [1]]
 >>> a[0][0] = 2
>>> a
[[2], [2], [2], [2], [2], [2], [2]]

why not

[[1], [2], [2], [2], [2], [2], [2]]

?

thank you !
-- 
Abdur-Rahmaan Janhangeer
https://github.com/abdur-rahmaanj
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to