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 jenda.petrov@gmail.com
Recipients jenda.petrov@gmail.com
Date 2012-12-23.16:33:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1356280383.46.0.680609909291.issue16756@psf.upfronthosting.co.za>
In-reply-to
Content
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])
History
Date User Action Args
2012-12-23 16:33:03jenda.petrov@gmail.comsetrecipients: + jenda.petrov@gmail.com
2012-12-23 16:33:03jenda.petrov@gmail.comsetmessageid: <1356280383.46.0.680609909291.issue16756@psf.upfronthosting.co.za>
2012-12-23 16:33:03jenda.petrov@gmail.comlinkissue16756 messages
2012-12-23 16:33:03jenda.petrov@gmail.comcreate