<br clear="all"><div>Hi all,</div><div><br></div><div>I have a doubt regarding how the list work in following case-</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>>>> ls=[[0]*5]*5</div>
</div><div><div>>>> ls[1][1]+=1</div></div><div><div>>>> ls</div></div><div><div>[[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]]</div></div></blockquote><div><br></div>
<div>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??</div>-- <br>Regards,<div>Rishabh Dixit</div><div>MSc.(Tech) Information Systems,</div><div>BITS Pilani</div>
<br>