Skip to content

Instantly share code, notes, and snippets.

@d136o
Created October 4, 2016 18:45
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 d136o/7070dea358b26c4fd311f5ff27d21b78 to your computer and use it in GitHub Desktop.
Save d136o/7070dea358b26c4fd311f5ff27d21b78 to your computer and use it in GitHub Desktop.
understand shortcuts before using them :)
$ python
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [[0,0],[0,0]]
>>> c = (1,1)
>>> a[c[0]][c[1]] = 100
>>> a
[[0, 0], [0, 100]]
>>> a = [[None]*2]*2
>>> a
[[None, None], [None, None]]
>>> a[c[0]][c[1]] = 100
>>> a
[[None, 100], [None, 100]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment