Space Python Loading Python…

Path in a config

Fix the codeEasy 2 stages

The ground station keeps its telemetry on a Windows computer, and a config script tells the software where to save it. Someone wrote the path the way Windows shows it, and this is what the script printed:

Telemetry file: C:\missions
ew	elemetry.txt

In Python text, a backslash starts an escape sequence: \n is a new line and \t a tab. That's exactly what happened to \new and \telemetry. Get the paths to print the way Windows writes them.

Run the script and look at the output: the path is split across two lines, with a strange gap in the middle. Fix the path so the script prints:

Telemetry file: C:\missions\new\telemetry.txt

Put an r right before the opening quote of the path. That makes it a raw string, in which a backslash is just a backslash.

Print the path as Windows writes it
Use a raw string

Finish stage 1 to unlock this stage.

The config now also names the archive folder, and folder paths often end with a backslash. Run it: this time Python doesn't even start. A raw string can't end with a backslash, because \" still stops the quote from closing the text. Fix the folder path so the script prints:

Telemetry file: C:\missions\new\telemetry.txt
Archive folder: C:\missions\archive\

Write the folder as a normal string and double every backslash: \\ stands for one backslash.

Get the config running
Print both paths
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

Special Characters in Print

special-characters-print.py
# Special characters in Python
# \n - new line
print("Mission log:\nDay 1: Launch\nDay 2: Orbit reached\nDay 3: Systems check")

# \t - tab (great for aligning columns)
print("\nPlanet\t\tDistance")
print("Mars\t\t225 mln km")
print("Jupiter\t\t778 mln km")
print("Saturn\t\t1,434 mln km")

# \\ - backslash (for file paths)
print("\nLog file: C:\\missions\\launch_data\\report.txt")

# \" and \' - quotes inside strings
print("Captain said: \"Initiate launch sequence!\"")
print('Engineer\'s reply: "All systems go."')
Open the full example
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:].