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

ParameterTypeDefaultDescription
*objectsAnyZero or more objects to print
sepstr' 'String inserted between objects
endstr'\n'String appended after the last object
filetext streamsys.stdoutStream to write output to
flushboolFalseWhether 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)

See Also