print()
Writes the given values to the screen.
Syntax
print(*values, sep=' ', end='\n')
Description
Prints the value(s) inside the parentheses to the screen. You can pass several values separated by commas; by default it puts a space between them and moves to a new line at the end. You can change this behavior with sep and end.
Parameters
| *values | One or more values to print. |
| sep(optional) | The separator placed between values (default: a space). |
| end(optional) | The text added at the end of the line (default: a newline). |
Returns
Returns nothing (None); it writes to the screen.
Example
Loading editor…
Expected output
Hello World A-B-C side by side continues
When to use?
The most-used command for showing a program's result to the user and for seeing variables' values while debugging.
Common mistakes
- ⚠️ Forgetting to put the text in quotes: print(Hello) gives an error, print("Hello") is correct.
- ⚠️ Forgetting that sep and end are only given as keyword arguments.