New submission from void abuser <void4bu...@gmail.com>:

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]]

----------
components: Regular Expressions
files: bug.png
messages: 381698
nosy: ezio.melotti, mrabarnett, void4buser
priority: normal
severity: normal
status: open
title: Adding number to a declared 2 dimension list
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49615/bug.png

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42449>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to