Before every real launch, the flight director asks each station: go or no-go? Rocket wants a program that runs the poll and lists every problem it finds, not just the first one.
"Last time I typed Yes with a capital letter and it said the crew was not ready," he says. "That felt unfair."
Raven nods slowly. "What do you notice?" she asks. "Yesterday we saw that go and Go are different strings. Users will type capitals, spaces, anything."
Nova projects a tiny broom sweeping up stray spaces. "Interesting," she says. "Strings have tools that clean them up before you compare. Look for strip and lower."
Rocket adds the cleanup step, then a counter for problems.
.strip() removes spaces from the start and end of a string. .lower() makes every letter lowercase. Chained together, input().strip().lower() turns " YES " into "yes".
This program uses separate if statements, not elif, because it should check every station and report every problem.
# go_no_go.py
print("Go or no-go poll")
fuel = int(input("Fuel percent: "))
weather = input("Weather (clear, windy, stormy): ").strip().lower()
crew = input("Crew ready? (yes/no): ").strip().lower()
problems = 0
if fuel < 80:
print("* Fuel is below 80 percent.")
problems = problems + 1
if weather != "clear":
print("* Weather is not clear.")
problems = problems + 1
if crew != "yes":
print("* Crew is not ready.")
problems = problems + 1
if problems == 0:
print("All stations GO. Launch approved!")
else:
print(f"HOLD: {problems} problem(s) found.") A run where everything is ready, typed with capital letters:
Go or no-go poll Fuel percent: 90 Weather (clear, windy, stormy): Clear Crew ready? (yes/no): YES All stations GO. Launch approved!
A run with two problems:
Go or no-go poll Fuel percent: 70 Weather (clear, windy, stormy): windy Crew ready? (yes/no): yes * Fuel is below 80 percent. * Weather is not clear. HOLD: 2 problem(s) found.
Users might type yes, y, YES or even " Y ". Clean the answer first, then use or to accept more than one spelling.
# yes_check.py
answer = input("Doors sealed? ").strip().lower()
if answer == "yes" or answer == "y":
print("Doors confirmed")
else:
print("Doors not confirmed") | Statement | True or false? |
|---|---|
| .lower() changes YES into yes. | ? |
| .strip() removes spaces from the middle of a string. | ? |
| answer == "yes" or answer == "y" accepts either spelling. | ? |
| Separate if statements stop after the first True one. | ? |
You built a real decision tool that cleans its input and checks every rule. Next week your programs learn to repeat.