# basics loops

Counting Down with a Step

range() can take a third number — the step size. A negative step counts down instead of up:

for i in range(10, 0, -2):
    print(i)

prints:

10
8
6
4
2

Your turn: read a number n. Print a countdown from n down to 1 (inclusive), one per line, using range(n, 0, -1).

💡 need a hint?

pyb-loop-range-step.py🔒 given lines are locked — write your code in between
loading...