Space Python Loading Python…

Progress on one line

Write the codeEasy 3 stages

When the ground station uploads a flight plan to Python One, the console first shows what it's doing and then, once it's finished, how it went. Command-line tools do this all the time: you see Uploading flight plan... while you wait, and done appears on the same line when it's over.

The catch is that every print() ends with a new line, so two prints give two lines. Change how they end.

The two prints show up on two lines. In a real upload, the first one appears right away and the second only when the upload has finished, so keep them as two separate prints. Make them share one line:

Uploading flight plan... done

Give the first print() the argument end=" ": it then ends with a space instead of a new line.

Show the result on the same line
Keep two separate prints

Finish stage 1 to unlock this stage.

The full upload has three steps, and each prints its result when it finishes. Put every step and its result on one line:

Uploading flight plan... done
Verifying checksum... OK
Activating plan... done

Only the prints that show a step need end=" ". The results keep their normal ending, which starts the next line.

One line per step
Keep the prints separate

Finish stage 2 to unlock this stage.

While the link comes up, the ground station prints a dot every second, on the same line as the message that says what it's waiting for. Then the result goes on a new line:

Waiting for ground station...
Link established

This time the dots touch the text, with no spaces, so use end="". Think about which print has to finish the line.

Dots on the waiting line
One print per dot
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

Print Parameters sep and end

print-parameters-sep-end.py
# Parameter sep changes the separator between items
print("Mercury", "Venus", "Earth", "Mars")
print("Mercury", "Venus", "Earth", "Mars", sep=" -> ")
print("Mercury", "Venus", "Earth", "Mars", sep="\n")

# Parameter end changes what appears at the end of print
print()
print("Countdown:", end=" ")
print("3", end="... ")
print("2", end="... ")
print("1", end="... ")
print("LAUNCH!")
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:].