Python print() Function Explained
The Python print() function displays output in the terminal or console. It is one of the first functions beginners learn because it lets you show text, numbers, variable values, and calculation results.
This page explains the basic syntax of print(), its most useful optional arguments, and common beginner mistakes.
Quick example
name = "Mia"
age = 12
print(name)
print(age)
print("Hello", name)
Output:
Mia
12
Hello Mia
Use print() to show text, numbers, and variable values on the screen.
What print() does
print() sends output to the screen.
You can use it to display:
- text
- numbers
- variables
- expressions
Example:
print("Hello")
print(5)
print(2 + 3)
Output:
Hello
5
5
A very important detail is that print() returns None. Its job is to display something, not to give you a value back.
Basic syntax
The basic form is:
print(object1, object2, ...)
You can pass:
- one value
- many values
- strings, numbers, variables, or expressions
Example:
print("Apple")
print("Score:", 10)
print("Total:", 4 + 6)
Output:
Apple
Score: 10
Total: 10
In Python 3, the parentheses are required.
Printing different kinds of values
You can print several kinds of data with print().
Print text
Text must be inside quotes.
print("Hello")
print("Python is fun")
Print numbers
Numbers do not use quotes.
print(5)
print(3.14)
Print variables
score = 99
print(score)
Print expressions
print(2 + 3)
print(10 * 4)
If you are not sure what counts as text, see Python strings explained.
Using multiple arguments
print() can take more than one argument.
By default, Python places a space between them. This is often the easiest way to combine labels and variable values.
name = "Ava"
age = 10
print("Name:", name)
print("Age:", age)
Output:
Name: Ava
Age: 10
This is usually easier for beginners than joining values with +.
For example, this works:
age = 10
print("Age:", age)
But this causes an error:
age = 10
print("Age: " + age)
That fails because "Age: " is a string and age is an integer. If you want to combine them with +, you must first convert the number with str().
Important optional arguments
print() has a few optional arguments that are especially useful:
sepcontrols what goes between multiple valuesendcontrols what is added after the outputfilesends output to a file-like objectflushforces output to appear immediately
The most important ones for beginners are sep and end.
sep argument
The sep argument changes the separator between multiple printed values.
The default separator is a single space.
Default behavior
print("red", "green", "blue")
Output:
red green blue
Custom separator
print("red", "green", "blue", sep=",")
print("red", "green", "blue", sep=" - ")
Output:
red,green,blue
red - green - blue
sep only matters when you print more than one argument.
This is useful for simple formatting without building one long string yourself. If you want more control over formatting, see how to format strings in Python.
end argument
By default, print() ends with a newline. That means the next print() starts on a new line.
Default behavior
print("Hello")
print("World")
Output:
Hello
World
Stay on the same line
print("Hello", end="")
print("World")
Output:
HelloWorld
Add a custom ending
print("Hello", end="!\n")
print("World")
Output:
Hello!
World
The end argument is useful for:
- progress messages
- inline output
- custom punctuation at the end of printed text
print() returns None
A common beginner mistake is expecting print() to return the text it shows.
Example:
result = print("Hi")
print(result)
Output:
Hi
None
Why does this happen?
print("Hi")displaysHi- but the function itself returns
None - so
resultstoresNone
If you need to keep a value, assign the value itself instead of the print() call.
message = "Hi"
print(message)
This idea becomes clearer when you compare print() with functions like input(), which do return a value.
When beginners use print()
Beginners use print() in many simple but important ways:
- to display results to the user
- to show messages in a script
- to check variable values while debugging
- to inspect loops and function behavior
Example:
total = 0
for number in range(1, 4):
total += number
print("Current number:", number, "Total:", total)
Output:
Current number: 1 Total: 1
Current number: 2 Total: 3
Current number: 3 Total: 6
This kind of output is very helpful when you are trying to understand what your code is doing. For more debugging help, see how to debug Python code.
Common mistakes
Here are some common beginner problems when using print().
Forgetting quotes around text
This causes Python to think the word is a variable name.
print(Hello)
If Hello is not defined, Python raises an error.
Correct version:
print("Hello")
Using print without parentheses in Python 3
This is incorrect in Python 3:
print "Hello"
Correct version:
print("Hello")
Trying to join strings and numbers with +
This causes a TypeError.
age = 10
print("Age: " + age)
Fix it by using multiple arguments:
print("Age:", age)
Or convert the number first:
print("Age: " + str(age))
If you see this error, read TypeError: can only concatenate str not int to str.
Expecting print() to return a value
This does not store "Hello" in result:
result = print("Hello")
It stores None.
Misunderstanding sep and end
Remember:
sepchanges what goes between multiple valuesendchanges what appears after the output
Useful debugging commands
These simple print() examples can help you inspect your code:
print("Debug:", variable_name)
print(type(variable_name))
help(print)
What they do:
print("Debug:", variable_name)shows the current valueprint(type(variable_name))shows the value's typehelp(print)shows Python's built-in help forprint()
FAQ
Does print() add a new line automatically?
Yes. By default, print() ends with a newline. You can change this with the end argument.
Can print() show more than one value?
Yes. You can pass multiple arguments, and print() separates them with a space by default.
Why does print("Hello") return None?
Because print() is used for displaying output, not for returning data.
How do I print text and a number together?
Use multiple arguments:
print("Age:", 10)
You can also convert the number with str() if needed.
What is the difference between sep and end?
sepchanges the separator between multiple valuesendchanges what appears after the output