Skip to content

Instantly share code, notes, and snippets.

@anossov
Created February 20, 2013 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anossov/5000464 to your computer and use it in GitHub Desktop.
Save anossov/5000464 to your computer and use it in GitHub Desktop.
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]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment