Built-in Functions and Types

print()

Convert positional objects to text and write them to a text stream. sep separates values and end follows them; passing None for either uses its default. With no objects, only end is written. flush requests immediate flushing of Python stream buffers, not durable disk storage. print is useful for human-facing output and debugging; return values from functions when a caller needs data.

Formal Syntax & Structure

python syntaxpython
print(*objects, sep=' ', end='\n', file=None, flush=False)

Parameters & Attributes

NameTypeDescription
objectsobjectZero or more values converted with str().
sepstr | NoneKeyword-only separator, default one space.
endstr | NoneKeyword-only suffix, default newline.
filetext stream | NoneKeyword-only destination supporting write(str); default standard output.
flushboolKeyword-only request to flush the stream.

Return Value

None

Writes text as a side effect; does not return the displayed string.

Working Example

Example Snippetpython
from io import StringIOreport = StringIO()print("items", 3, sep=": ", file=report, end="!")print(report.getvalue())print("A", "B", sep="|")
Python Reference