KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
A previous question with the same title as mine has been posted , with (I think) the same question, but had other problems in the code. I was not able to determine if that case was identical to mine or not. Anyway, I want to replace an element within a list in a list. Code: myNestedList = [[0,0]]*4 # [[0, 0], [0, 0], [0, 0], [0, 0]] myNestedList[1][1] = 5 I now expect: [[0, 0], [0, 5], [0, 0], [0, 0]] But I get: [[0, 5], [0, 5], [0, 5], [0, 5]] Why? This is replicated in the command line. Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) [GCC 4.4.3] on linux2
Tags (comma-separated)
Save Edits
Cancel