>>> '[[0]*2]*2'
'[[0]*2]*2'
>>> `[[0]*2]*2`
'[[0, 0], [0, 0]]'
The first is text, the second is immediately in the data structure and returns its textual representation '[[0, 0], [0, 0]]'.
The problem with this [[0]*2]*2is that it refers to a list of links to the same object. That is why you get [[1,0],[1,0]], not [[1,0],[0,0]].
source
share