liveBook · Manning

Enumerate

enumerate is an iteration utility that yields pairs containing sequential indices and corresponding items from an iterable, optionally starting at a specified index.

How 3 Manning books explain it

Python How-To

The enumerate function is a Python built-in function that returns an iterator producing position-and-item pairs from an iterable.

How it is used
Improves for-loop iteration when each item must be displayed or processed with its position.
How deep it goes
Explains iterator creation, yielded tuples, default counters, start values, and tuple unpacking through worked loops.
Examples
Demonstrates numbered prime numbers and formatted task records using zero-based and one-based counters.
What you can do after
Apply it via Python's built-in enumerate function to write readable position-aware loops.

Read how Python How-To explains enumerate →

Python Workout, Second Edition

The enumerate function returns an iterator that yields pairs containing sequential indices and values from an iterable.

How it is used
Uses indexed iteration to solve loops that need positions alongside values, especially when processing strings.
How deep it goes
Explains returned pairs, unpacking, default indexing, and custom starts; connects iterator behavior to broader protocol study.
Examples
Demonstrates indexed alphabet output, hexadecimal digit processing, and alphabet-to-number dictionary construction.
What you can do after
Apply it via Python's built-in iterator to write concise loops and comprehensions that retain both positions and values.

Read how Python Workout, Second Edition explains enumerate →

Tiny Python Projects: Learn coding and testing with puzzles and games

enumerate() is a Python built-in function that produces pairs of indexes and values while iterating an iterable.

How it is used
Uses index-and-value iteration to format a Tic-Tac-Toe board and label empty cells.
How deep it goes
Defines returned pairs, default and custom starts, laziness, unpacking, and equivalent loop and comprehension forms.
Examples
Demonstrates board strings, REPL enumeration, numbered cells, and a tested format_board() function.
What you can do after
Apply it via Python to iterate values alongside positions and format indexed output.

Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains enumerate →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.