Python lesson 8 of 50 · Beginner · About 25 minutes
Pip must confirm four stations before rolling out. Use loops to broadcast every preflight check and count down to launch.

Mission Loop over station names and use range to display a countdown.
Get ready
Read this as the next checkpoint in Pip’s mission. You can also start with the complete program below.
Open the browser Python editor (opens in a new tab), replace its example with the complete checkpoint below and choose Run. Use Python 3.10 or newer.

Understand the Python in this lesson
Read the explanations, then follow the worked example before changing the code.
Store the checklist in order
The list in stations stores the places to check. Python reads a list from left to right during this loop, so the list decides which check appears first, second, third and fourth.
Give each item a temporary name
for station in stations: asks Python to take one item at a time from the collection and call it station on this turn. The singular name stands for one place. The plural name stands for the whole list.
Indent what should repeat
The message print(f"Check {station}") is inside the loop because it is indented. Each time it runs, the f-string uses the current item. After the last item, execution moves to the next unindented instruction.
Make the countdown with range
range(3, 0, -1) gives a start of three, a stopping point of zero and a step of minus one. Python uses three, two and one. The stopping point is excluded, so zero never becomes the value of number.
Put the launch outside the loop
The countdown loop prints a number once per turn. print("Launch!") comes after it at the left margin. That placement makes the launch message appear once when the countdown has finished.
How the pieces fit Use a for loop when there is a collection or sequence to work through. The loop header supplies one value per turn and the indented body uses it.
-
Start the station loop.
Check Habitat, Check Workshop, Check Greenhouse, Check Beacon appear on separate lines. Why Each item becomes station for one run of the same print instruction. -
Start the number loop.
3, 2 and 1 appear on separate lines. Why Range counts backwards by one up to, but excluding, the stop value of zero. -
Reach the last unindented line.
Launch! Why The final call is after both loops, so it runs once.
Predict before you run Predict what appears if you indent the final print line so it sits directly below print(number) inside the countdown loop.
Reveal the explanation
Launch! would appear after each number, three times in all. Move it back to the left margin to launch just once at the end.
Build the checkpoint
Python skills for, Iterating over a list, range(), Countdowns.
1. Read the stations in order
Put the four station names into a list. A for loop visits each item one after another, from the first to the last. The name station refers to one item for one turn of the loop. The indented message can use that name to display whichever station it is checking.
for station in stations:
print(f"Check {station}")
2. Build a descending count
Use range(3, 0, -1) to produce numbers for a countdown. The first value is the starting number. The second tells Python where to stop and is excluded. The third makes each new number one less than the previous number. That gives three, two and one, then the loop ends.
for number in range(3, 0, -1):
print(number)
3. Launch once, after the loops
Put the launch message at the far left under the second loop. Python first completes all the station checks, then completes the countdown and finally prints the launch message once. If you try changing the countdown or the order of checks, listen for that last message to confirm the flow still works.
print("Launch!")
Complete Python checkpoint · moonbase_08.py
stations = ["Habitat", "Workshop", "Greenhouse", "Beacon"]
print("Preflight stations:")
for station in stations:
print(f"Check {station}")
print("Launch countdown:")
for number in range(3, 0, -1):
print(number)
print("Launch!")Read the complete checkpoint line by line
Use this guide beside the checkpoint. Blank lines separate ideas. Indented lines belong to the instruction above them. Lines with brackets still open can carry on below.
Lines 1–10
-
Line 1
stations = ["Habitat", "Workshop", "Greenhouse", "Beacon"] - Work out the value on the right, then store it in stations.
-
Line 2
print("Preflight stations:") - Show the message or value in the output.
-
Line 3
for station in stations: - Take one item at a time and give it to station, then run the indented block.
-
Line 4
print(f"Check {station}") - Show the message or value in the output. Python fills the braces with values before it uses the text.
-
Line 6
print("Launch countdown:") - Show the message or value in the output.
-
Line 7
for number in range(3, 0, -1): - Take one item at a time and give it to number, then run the indented block. Generate a sequence of integers that stops before the final limit.
-
Line 8
print(number) - Show the message or value in the output.
-
Line 10
print("Launch!") - Show the message or value in the output.
Test the mission
- Run the full checklist and name the two loops that printed it.
- Change 3 to 5 in range. Verify the first number is five and the count still ends at one.
- Add a station to the list. Confirm it gets its own check with no new print instruction.
If something goes wrong
- I get a launch message after every number.
- Remove indentation from print("Launch!") so it runs after the countdown.
- The countdown is missing a number.
- Check that the stop value is exclusive. Use 0 as the stop if you need to include 1.
Mission extension
Add a second checklist just for tools. Use a list and for loop, then show how many checks the two lists contain in total.