[issue16756] buggy assignment to items of a list created by a * operator

2012-12-23 Thread Christian Heimes
Christian Heimes added the comment: The outcome is correct. You have fallen for a common beginners gotcha: http://www.enricozini.org/2011/tips/python-list-gotcha -- nosy: +christian.heimes resolution: -> invalid status: open -> closed ___ Python tra

[issue16756] buggy assignment to items of a list created by a * operator

2012-12-23 Thread jp
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, in