Skip to content

Instantly share code, notes, and snippets.

@jfriedly
Created July 11, 2013 22:23
Show Gist options
  • Save jfriedly/5979784 to your computer and use it in GitHub Desktop.
Save jfriedly/5979784 to your computer and use it in GitHub Desktop.
How to iterate over something with an index using enumerate. Keywords: counter, i, iterable, list, dict, dictionary, Python
>>> for index, letter in enumerate('foobar'):
...     print index, letter
...
0 f
1 o
2 o
3 b
4 a
5 r
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment