Shows values on the screen.
Synopsis
print(value)
print(value1, value2, ...)
print(value, end="")
print(value1, value2, sep="")
Description
print shows each value you give it, with a space between them, then moves to a new line. It works with any type: strings, numbers, lists.
Parameters
| Name | Meaning |
|---|---|
value |
One or more values to show, separated by commas. |
sep |
What goes between the values. The default is one space, " ". |
end |
What goes after the last value. The default is a new line, "\n". |
Return value
Nothing (None). What print does is a side effect: text appears on the screen.
Example
print("hello, world")
print("x is", 5)
print("a", "b", "c", sep="-")
print("no new line", end="")
print("!")
It prints:
hello, world
x is 5
a-b-c
no new line!
Common mistake
Print("hello, world")
Python stops with:
NameError: name 'Print' is not defined
Python is case-sensitive. The function is print, all lowercase.
See also
Last updated 2 weeks ago