public
Created

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
In [1]: l1 = [[[0]*3]*3]*3
 
In [2]: l1
Out[2]:
[[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]
 
In [3]: l1[0][0][0] = 'x'
 
In [4]: l1
Out[5]:
[[['x', 0, 0], ['x', 0, 0], ['x', 0, 0]],
[['x', 0, 0], ['x', 0, 0], ['x', 0, 0]],
[['x', 0, 0], ['x', 0, 0], ['x', 0, 0]]]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.