Python print() Function
print(*objects, sep=' ', end='\n') converts each value to text, joins them with sep, writes the result followed by end and returns None.print() is the first function most people meet in Python. It is how a script shows a result, a message or a value you want to inspect while debugging. You can give it as many values as you like, of any type, and it turns each one into text for you.
Because it only shows things, print() is not a way to hand a value back from a function. For that you need return, which is explained in print vs return. The basics of screen output are also covered in the input and output lesson.
| Syntax | print(*objects, sep=' ', end='\n', file=None, flush=False) |
|---|---|
| Parameters | objects: zero or more values to show; sep: text placed between values; end: text added at the end; file: where to write (default sys.stdout); flush: force the output out immediately |
| Returns | None |
| Python version | Works the same in every Python 3 release; Python 2 used a statement without parentheses |
How print() turns values into text
For every value you pass, print() calls str() on it, so numbers, lists, booleans and None all display without any manual conversion. Values are separated by one space unless you change sep, and a newline is added at the end unless you change end.
price = 19.5
print("Price:", price, True, None)
print()
print("done")Calling print() with no arguments just prints an empty line, which is handy for spacing out a report.
print() parameters: sep, end, file and flush
| Parameter | Default | What it changes | Example |
|---|---|---|---|
sep | ' ' | Text placed between the values | print(1, 2, 3, sep='-') gives 1-2-3 |
end | '\n' | Text written after the last value | print('Loading', end='...') stays on the same line |
file | sys.stdout | The object to write to, such as sys.stderr or an open file | print('oops', file=sys.stderr) |
flush | False | Pushes buffered output out straight away | print('tick', flush=True) |
Printing formatted output with f-strings
When a line mixes text and values, an f-string is clearer than passing many comma-separated arguments and lets you control decimals and alignment.
student = "Asha"
score = 87.456
print(f"{student} scored {score:.1f}")Use print(a, b) for quick checks and f-strings when the exact layout matters.
print() in loops and with unpacking
Putting a * in front of a list passes each item as a separate argument, which together with sep gives a tidy one-line list without brackets. Inside a for loop you can use end to keep several values on one line.
Examples you can run
Press Run, then edit the code and run it again.
Change the separator and the ending
sep goes between values and end replaces the final newline.
print("2025", "06", "30", sep="-")
print("Loading", end="...")
print("done")Expected output2025-06-30
Loading...done
Print a shopping cart on one line
Unpacking the list with * prints every item as its own argument.
cart = ["pen", "notebook", "ruler"]
print(cart)
print(*cart, sep=", ")
print("Items:", len(cart))Expected output['pen', 'notebook', 'ruler']
pen, notebook, ruler
Items: 3
print() returns None
The text appears on screen, but the value the call gives back is None.
result = print("hello")
print(result)Expected outputhello
None
Common mistakes
Joining text and a number with +
✗ Wrong
age = 30
print("Age: " + age)✓ Right
age = 30
print("Age:", age)
print(f"Age: {age}")+ cannot join a string and an int. Pass them as separate arguments, convert with str(), or use an f-string.
Writing print without parentheses
✗ Wrong
print "hello"✓ Right
print("hello")In Python 3 print is a function, so it always needs parentheses.
Expecting print() to give back a value
✗ Wrong
def total(a, b):
print(a + b)
x = total(2, 3)
print(x + 1)✓ Right
def total(a, b):
return a + b
x = total(2, 3)
print(x + 1)The function printed the sum but returned None. Use return a + b when the caller needs the value.
Python print() Function: questions people ask
How do I print without a newline in Python?
Pass end='' to print(), for example print('Loading', end=''). The next print call then continues on the same line.
How do I print multiple values on one line in Python?
Give print() several arguments separated by commas, such as print('Total:', 42). They are joined with a space, or with whatever you set in sep.
What does print() return in Python?
print() returns None. Its job is the side effect of writing text, not producing a value you can reuse.
Keep learning
Step-by-step lessons:
Python Input and OutputPython f-Strings
Related:
Python print() vs return: What Is the Difference?Python input() FunctionPython str() FunctionPython String format() Method
More in built-in functions:
Python len() FunctionPython range() FunctionPython type() FunctionPython int() FunctionPython float() FunctionPython str() FunctionPython input() FunctionPython sum() Function See all →