The Python print() Function

Getting comfortable with print()

Beginner 8 min

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).

Example
print("You have", 3, "new messages")
Output
You have 3 new messages
Mixing text and a number in one call.

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)

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.

Example
print("Loading", end="...")
print("done")

print("Phone Number", end=": ")
print(123, 456, 7890, sep="-")
Output
Loading...done
Phone Number: 123-456-7890
Changing end so two prints stay on one line.

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.

Example
count = 3
print("You have", count, "new messages")
print(f"You have {count} new messages")
Output
You have 3 new messages
You have 3 new messages
The same line, the comma way and the f-string way.

Common mistake: Capitalising Print or dropping the parentheses

Why it happens:

Python is case-sensitive and expects print(...) exactly. Print or print "hi" (no parentheses) are not valid.

How to fix it:

Always write lowercase print followed by parentheses: print("hi").

print("hi")

Common mistake: Forgetting the quotes around text

Why it happens:

Without quotes, Python thinks the word is a variable name and complains it isn’t defined (a NameError).

How to fix it:

Wrap any literal text in quotes: print("hello"), not print(hello).

What does print("Hi", "there") display?

Which prints the number forty-two (not the text)?

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:")

What to learn next

You got comfortable with print(): showing strings and numbers, passing several comma-separated values in one call, and the sep and end behaviours. You put it together by printing “Total: 15 items” from three separate values at once.

So far your programs forget every value the moment they finish. Variables fix that by giving values names you can reuse. Variables Explained Simply shows what a variable actually is and how assignment works. When you’re ready, continue to the next lesson.