Solution: Countdown
Explore how to write a Python program that counts backward from 5 to 1 using a for loop and prints a final message, helping you understand loops and basic automation.
We'll cover the following...
We'll cover the following...
This program counts backward from 5 to 1 and then prints “Liftoff!” — just like a rocket countdown!
range(5, 0, -1)means:Start at 5
Stop before 0
Count down by 1 each time (because of the
-1step).
The
forloop prints each number — 5, 4, 3, 2, 1 — one at a time.After the loop finishes,
print("Liftoff!")runs once to display the final message.