Dev Helpers

Python / Lists and tuples

Enumerate from one

Dev Helpers · December 31, 2025

Human-facing row numbers often start at one while sequence indexes start at zero. enumerate accepts a display offset directly.

Worked example

print(list(enumerate(['red', 'blue'], start=1)))

Result

[(1, 'red'), (2, 'blue')]

Implementation notes

The display number depends on the current traversal. Avoid using an enumerated row number as a persistent identifier after sorting or filtering.

Try it yourself

Remove the first item and check whether the numbers are labels or durable IDs.

Open the Python example →

Editorial date December 31, 2025 · Published December 6, 2026

Related articles

Transpose a matrix

Transposing rows into columns assumes a decision about uneven rows. Ordinary zip stops at the shortest input.

Unpack with a remainder

Starred unpacking separates a fixed header from a variable-length tail. It still requires enough elements for the fixed positions.

Flatten one level

A one-level flatten turns a sequence of groups into a sequence of members. Deeper lists remain members in their own right.