This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author void4buser
Recipients ezio.melotti, mrabarnett, void4buser
Date 2020-11-23.22:06:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606169199.89.0.319403348996.issue42449@roundup.psfhosted.org>
In-reply-to
Content
So basically the bug that I found was about adding a number to a sub-list.
If you declare li1 as li1=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] in the code below then the code is working as it should do.
Although if you create the list called li1 with the same way how I did in the code below (which has the same outcome in terms of looking at that 2 dimension list) then the output is different and in fact false.
The code:
li1=[[0]*4]*4 for x in range(4): li1[0][1]+=1 print(li1)
Expected behavior
Expected output:
[[0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
[[0, 2, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
[[0, 3, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
[[0, 4, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
The output that I got:
[[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]]
[[0, 2, 0, 0], [0, 2, 0, 0], [0, 2, 0, 0], [0, 2, 0, 0]]
[[0, 3, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0]]
[[0, 4, 0, 0], [0, 4, 0, 0], [0, 4, 0, 0], [0, 4, 0, 0]]
History
Date User Action Args
2020-11-23 22:06:39void4busersetrecipients: + void4buser, ezio.melotti, mrabarnett
2020-11-23 22:06:39void4busersetmessageid: <1606169199.89.0.319403348996.issue42449@roundup.psfhosted.org>
2020-11-23 22:06:39void4buserlinkissue42449 messages
2020-11-23 22:06:39void4busercreate