← Python from Scratch Lesson 26 of 78 · 5 XP

Warm-up: countdown warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

while repeats a block while the condition is true. For the loop to end some day, something inside it must change:

n = 3
while n > 0:
    print(n)
    n = n - 1     # decrease it, otherwise the loop never stops
print("Go!")

It prints 3, 2, 1, Go!.

Task. Read a number n and count down from n to 1, then print Go! at the end.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.