enumerate() can be used with any iterable. It enumerates the values returned by the iterable.
3>> enumerate(['a', 'b', 'c'])
<enumerate object at 0x7f1340c44a50>
3>> list(enumerate(['a', 'b', 'c']))
[(0, 'a'), (1, 'b'), (2, 'c')]
3>> list(enumerate({'a', 'b', 'c'}))
[(0, 'c'), (1, 'b'), (2, 'a')]
3>> list(enumerate({'a':0, 'b':0, 'c':0}))
[(0, 'c'), (1, 'b'), (2, 'a')]
Note that the set and dict results are not in error; they are arbitrarily ordered, hence do not necessarily "come out" the same way they "go in". And as always, iterating over a mapping yields its keys.
enumerate()does. What exactly about the examples is unclear?iteratorisn't immediately clear and what the__next__()method on an iterator does. But both concepts link to further documentation as well.enumerate()can be used on any iterable, including otherenumerate()results.