Hi all,

I have a doubt regarding how the list work in following case-

>>> ls=[[0]*5]*5
>>> ls[1][1]+=1
>>> ls
[[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1,
0, 0, 0]]


Here, according to me only one value in ls should be incremented but it is
increasing 1 value in all the lists of ls. Why??
-- 
Regards,
Rishabh Dixit
MSc.(Tech) Information Systems,
BITS Pilani
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to