Back
+10 XP
Concept

The range() Function

Need to loop $N$ times? Use `range()`:

python
for i in range(3):        # 0, 1, 2 (stops before 3!)
    print(f"Ping {i}")

# 59. The range() Function Need to loop $N$ times? Use `range()`: ```python for i in range(3): # 0, 1, 2 (stops before 3!) print(f"Ping {i}") ``` Parameters: `range(start, stop, step)`: - `range(1, 4)` gives `1, 2, 3` - `range(0, 6, 2)` gives `0, 2, 4` (hops by 2)

Checkpoint

What numbers does `range(1, 4)` produce?

Practice

Use `range()` to count down from 3 to 1 (`range(3, 0, -1)`), printing each number.

Terminal
01
Tap code blocks below to assemble
Available Blocks