Python·100 questions

How does enumerate work and why is it convenient?

Answer
enumerate(iterable) gives (index, value).
Example: for i, item in enumerate(items, start=1): ...
Eliminates manual counter.
Works with any iterator.
Improves readability.
Was this answer helpful?

More questions in this topic

Related questions from other topics