print()
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) Returns:
None · Updated March 13, 2026 · Built-in Functions output built-in console
The print() function writes the string representation of the given objects to the standard output stream.
Syntax
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
*objects | Any | — | Zero or more objects to print |
sep | str | ' ' | String inserted between objects |
end | str | '\n' | String appended after the last object |
file | text stream | sys.stdout | Stream to write output to |
flush | bool | False | Whether to force-flush the stream |
Examples
Basic usage
print("Hello, World!")
# Hello, World!
print("Python", 3.12)
# Python 3.12
Custom separator
print("2026", "03", "06", sep="-")
# 2026-03-06
print(*range(5), sep=", ")
# 0, 1, 2, 3, 4
Custom end character
for i in range(3):
print(i, end=" ")
# 0 1 2
Writing to a file
with open("output.txt", "w") as f:
print("Log entry", file=f)
Flushing output
import time
for i in range(5):
print(f"\rProgress: {i+1}/5", end="", flush=True)
time.sleep(1)
Common Patterns
Debugging with f-strings
name = "Alice"
age = 30
print(f"{name=}, {age=}")
# name='Alice', age=30
Pretty-printing data structures
For complex objects, use pprint from the standard library instead:
from pprint import pprint
data = {"users": [{"name": "Alice"}, {"name": "Bob"}]}
pprint(data)