Space Python Loading Python…

Read the error

Fix the codeEasy 3 stages

Python's error messages look scary at first, but they're the most useful thing a broken program gives you. The last line says what went wrong, and the line above it says where: File "script.py", line 7.

The flight log script on Python One won't run. Don't read the whole file looking for the problem. Run it, read the line number in the error, and go straight there.

Run the script. Python stops before printing a single line and shows a SyntaxError. Find line and a number in the error, go to that line in the editor (the numbers are on the left) and fix it. The rest of the file is fine. When it works, the script prints:

Day 1 flight log
08:00 Crew wake-up
08:30 Breakfast and medical check
09:15 Navigation update received
10:00 Course correction burn: 12 s
10:20 Burn confirmed by ground control
11:00 Science block begins
End of log
Get the log running
Print the whole log

Finish stage 1 to unlock this stage.

The next day, the flight engineer pasted one line into the log straight from a chat message, and the script won't run again. Run it, read the error and go to the line it names. Look closely: the marks around the text look like quotes, but they aren't the ones Python accepts. Fix the line so the log prints:

Day 2 flight log
08:00 Crew wake-up
09:40 Docking port 2 inspected
12:30 Docking port 2 pressurised
14:00 Cargo transfer begins
End of log
Get the log running
Print the whole log

Finish stage 2 to unlock this stage.

Day 3 has two mistakes, on different lines. Python reports only the first one it finds, so after you fix it and run again, a different error appears, on a different line. Fix them one at a time, running after each fix, until the log prints:

Day 3 flight log
08:00 Crew wake-up
10:15 Solar panel 2 rotated
13:00 Water recycler filter changed
16:45 Earth photos sent to ground control
End of log
Get the log running
Print the whole log
You're not logged in, so your progress is kept in this browser only. Log in to save it, and to use hints and solutions.

Hints

script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].