Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

2 matching syntax entries

Iteration with enumerate and zip

Learn in depth →

A for loop requests successive values from an iterable. enumerate adds positions; zip combines streams.

for value in iterable: ...
enumerate(items, start=1); zip(left, right)

Example

for number, (name, score) in enumerate(zip(["Asha", "Om"], [8, 9]), start=1):
    print(number, name, score)

Result

1 Asha 8
2 Om 9

Watch for: zip stops at the shortest iterable by default. zip(..., strict=True) detects unequal lengths on Python 3.10+.

Practise this topic →

Ranges and loop else

Learn in depth →

range describes integer steps without storing a list. Loop else runs if no break occurred.

range(stop); range(start, stop, step)
for ...: ...
else: ...

Example

print(list(range(5, 0, -2)))
for n in [1, 3, 5]:
    if n % 2 == 0:
        break
else:
    print("no even value")

Result

[5, 3, 1]
no even value

Watch for: The stop is excluded. continue does not suppress loop else; break does.

Practise this topic →
Complete explanation index (91 lessons indexed)

Loops

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.