New submission from jp:
The following code:
li = [[1,0]]*5
a = [[1,10], [2,20], [3,30]]
for line in a:
li[line[0]][0] = 2
print(li)
prints [[2,0],[2,0],[2,0],[2,0],[2,0]], but should print
[[1,0],[2,0],[2,0],[2,0],[1,0]].
The output is correct if you, instead of using li = [[1,0]]*5, initialize the
array as follows:
li = []
for i in range(5): li.append([1,0])
----------
components: Interpreter Core
messages: 177995
nosy: [email protected]
priority: normal
severity: normal
status: open
title: buggy assignment to items of a list created by a * operator
versions: Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16756>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com