The Python print() Function
Getting comfortable with print()
In this lesson
The print() function displays text and values on the screen — it’s how you write a classic ‘Hello, world!’ program and see what your code is doing. You’ve seen print() already; now let’s understand it properly, because you’ll use it constantly.
Explain it like I’m 5
print() is how your program speaks out loud. Whatever you hand it inside the parentheses, it says on the screen.
Strings and numbers
print() can display strings (text in quotes) and numbers (no quotes). print("42") prints the text four-two; print(42) prints the number 42. They look the same on screen but behave very differently — you can do maths with the number but not with the text.
Printing several values at once
Pass multiple values separated by commas and print() shows them on one line with a space between each: print("Score:", 10) → Score: 10. This is handy for mixing labels (text) with values (numbers).
print("You have", 3, "new messages")
You have 3 new messages
Print a line that mixes a label and a number, like Age: 7. Try removing the quotes around the number and notice it still works because it's a real number.
print("Age:", 7)
Separate the label and the value with a comma; the number doesn't need quotes.
print("Age:", 7)
Age: 7
sep and end (nice to know)
By default print() puts a space between values and a newline at the end. You can change both: print("a", "b", sep="-") prints a-b, and end="" stops it moving to a new line. You won’t need these often, but it’s good to know the defaults can be changed.
print("Loading", end="...")
print("done")
print("Phone Number", end=": ")
print(123, 456, 7890, sep="-")
Loading...done Phone Number: 123-456-7890
Looking ahead: cleaner output with f-strings
Joining lots of values with commas works, but it gets fiddly once a line mixes several pieces of text and numbers. Python has a tidier tool for this — the f-string — which lets you drop values straight inside the text by writing an f before the quotes and putting variables in { }.
You don’t need it yet, but it’s worth seeing once. We cover it fully later — learn more about f-strings here.
count = 3
print("You have", count, "new messages")
print(f"You have {count} new messages")
You have 3 new messages You have 3 new messages
Common mistake: Capitalising Print or dropping the parentheses
Python is case-sensitive and expects print(...) exactly. Print or print "hi" (no parentheses) are not valid.
Always write lowercase print followed by parentheses: print("hi").
print("hi")
Common mistake: Forgetting the quotes around text
Without quotes, Python thinks the word is a variable name and complains it isn’t defined (a NameError).
Wrap any literal text in quotes: print("hello"), not print(hello).
What does print("Hi", "there") display?
Commas separate values, and print() joins them with a single space by default.
Which prints the number forty-two (not the text)?
No quotes means a real number; quotes make it a string. forty_two would be an undefined variable.
Mini exercise (easy)
Print a single line that reads: Total: 15 items — using a label, the number 15, and a word, all in one print().
Do it here. Finish the code below and press Run to try your answer right in the browser — no setup needed.
# Print exactly: Total: 15 items
# Use three comma-separated values in ONE print().
print("Total:")
Three comma-separated values: "Total:", 15, "items".
print("Total:", 15, "items")
Total: 15 items