Technical skill practice

enumerate in Python: Number Checklist Lines with start

enumerate in Python supplies a counter alongside each item you iterate over. Use start to choose the first displayed number. The counter is not automatically a persistent identifier: if the input order changes or items disappear, the same item may receive a different number.

Start with a small, explicit task

Prepare a numbered inspection checklist that begins at 7 because earlier items are shown elsewhere. Format each pair into a display line. Then check an empty checklist and a reordered copy. The item text is the data; the number belongs to this particular presentation.

Run the complete example

This original example was checked with Python 3.12.14. Save it as python_enumerate.py and run it with Python 3.12. It uses only the standard library. The assertions check the stated results.

Expected output

7. Inspect seal

8. Record temperature

9. Store sample

(7, 'Store sample')

checklist = ["Inspect seal", "Record temperature", "Store sample"]
pairs = list(enumerate(checklist, start=7))
lines = [f"{number}. {text}" for number, text in pairs]
assert pairs[0] == (7, "Inspect seal")
assert lines == ["7. Inspect seal", "8. Record temperature",
                 "9. Store sample"]
assert list(enumerate([], start=7)) == []
reordered = list(enumerate(list(reversed(checklist)), start=7))
assert reordered[0] == (7, "Store sample")
print("\n".join(lines))
print(reordered[0])

Explain the result

Each tuple contains the generated number first and the original checklist string second. The comprehension unpacks those positions as number and text. start=7 changes the counter’s first value; it does not skip the first seven input items. All three source items remain in the result.

Reversing the input makes Store sample receive 7, illustrating why the display counter should not replace a durable record ID. Empty input produces no pairs; start does not manufacture an item. Materializing pairs as a list is useful for inspection here, but a normal for loop can consume enumerate directly without creating that intermediate list.

Avoid these mistakes

Do not use the displayed number as a zero-based list index when start is nonzero. Keep any actual business identifier inside the item itself. If you filter a checklist, decide whether numbering should happen before filtering to preserve source positions or afterward to create consecutive visible numbers.

Questions, answered

Does start skip input items?

No. It sets the initial counter. The first checklist item still appears.

Can enumerate number an empty iterable?

There are no items to number, so the result is empty regardless of start.

Sources and examples

ResumizeAI team. Examples are fictional teaching material, not customer results. Replace sample details with your own facts.

Your experience. A complete resume.

Build in Resumize with ATS-friendly templates, guided editing and a live preview. Start free, then upgrade when you need more.

Free account required. Free-plan PDF exports include a watermark.