Built-in Functions and Types

enumerate()

Pair successive items with an integer counter, starting at zero unless another start is supplied. It works on general iterables, including generators, without building an index list. The counter is an ordinal in this traversal, not necessarily an index into the original object. The returned iterator is consumed as it is read.

Formal Syntax & Structure

python syntaxpython
enumerate(iterable, start=0)

Parameters & Attributes

NameTypeDescription
iterableiterableSource of items.
startinteger-likeInitial counter value, default zero.

Return Value

enumerate iterator

Yields two-item tuples (counter, item); exhausted after one traversal.

Working Example

Example Snippetpython
for number, task in enumerate(["draft", "review"], start=1):    print(number, task)
Python Reference