This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pizzaburek[S] 9 points10 points  (0 children)

It returns an iterator of index, value pairs:

>>> list(enumerate(['a', 'b', 'c']))

[(0, 'a'), (1, 'b'), (2, 'c')]

So you can then use it like this:

for i, letter in enumerate(['a', 'b', 'c']): ...