← Python lessons

Printing Output

print() displays a value on the screen. It is how you see what your program is doing — and your main tool for finding out why something went wrong.

Printing a value

print("Hello!")
print(42)

By default, print() ends with a newline, so these two calls produce two lines of output.

Printing several things at once

Separate values with commas. By default, print() displays them with one space between them.

score = 10
print("Score:", score)

Printing to debug

A temporary print can show a value while you investigate a problem:

name = "Ada"
print("name is:", name)

Put the print where the variable is available, using the same indentation as the surrounding code. Remove debugging output before submitting an exercise that requires specific output.

print is not return

Later, when you write functions, you will use return to give a result back to the code that called them. For this exercise, use print() to display text. See Parameters & Return.

See also: String Formatting for formatting the text you print.

Your turn

Print the message shown below using one print() statement.

# Add one print statement.

Expected output

Ready to begin!

Optional practice after learning variables: set lives = 3, then use print("Lives left:", lives) to display the label and value together.


Practise this in the free Python course, where every exercise checks your code instantly.