Sponsored Reserved space — layout preview until AdSense is connected

Enumerate with index

Loop with both index and value — cleaner than manual counters.

4 lines 5 views 0 copies Updated May 23, 2026
Try in editor

How it works

enumerate(iterable) yields (index, item) pairs starting at 0 by default.

Pass start=1 when you want human-friendly numbering in printed output.

Prefer enumerate over range(len(x)) — it is shorter and avoids index mistakes.

Python
Try in editor
tasks = ["read docs", "write code", "run tests"]

for i, task in enumerate(tasks, start=1):
    print(f"{i}. {task}")

Sponsored

Sponsored Reserved space — layout preview until AdSense is connected

Run this sample

Open the browser IDE to tweak the example and see results without installing anything.

Open editor

More from Lists & loops