print() Print to stdout
Last updated: 2026-09-22
print() Print to stdout
print() writes objects as strings to stdout (default); sep joins them, end is appended, file redirects output.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
⚙️ Parameters
| objects Optional | Zero or more objects to print (variadic), converted to strings automatically. |
|---|---|
| sep Optional | Separator inserted between objects, default a space.(Default:' ') |
| end Optional | String appended at the end, default a newline.(Default:\n) |
| file Optional | Output target; must have a write method.(Default:sys.stdout) |
| flush Optional | Whether to flush the stream immediately.(Default:False) |
Returns:Returns None; output is written to the stream given by file.
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
hello
a-b-c
no newline here
🏷️ Related Built-in Functions
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does print('a', 'b', 'c', sep='-') output?
AIt outputs a-b-c. sep sets the separator between multiple objects, which defaults to a space.
QHow do I print without a newline?
APass end='': print('x', end='') prints without a newline so the next print continues on the same line; end defaults to '\n'.
QCan print() output to a file?
AYes, print('text', file=f) writes to a file object, or print(..., file=sys.stderr) outputs to the standard error stream.
QWhat does print() return? What is the flush parameter for?
Aprint() returns None, so do not use it as a return value. flush=True immediately flushes buffered content to the output stream, useful for progress bars and real-time logging.