Python print() function
Show values on the screen (or write them to a file).
Syntax
print(*values, sep=" ", end="\n", file=None)
Converts each value to text and writes them separated by sep, followed by end. With no values it prints an empty line. print returns None: it shows a value, it does not give it back.
Parameters
| *values | any number of values, separated by commas |
| sep | text placed between values (default one space) |
| end | text placed after the last value (default a new line) |
| file | where to write; the screen by default |
Return value
None
Example
Code
print("Hello", "world") print(3, 4.5, True, None) print("a", "b", "c", sep="-") print("no new line", end=" ... ") print("continued") print() # an empty line name, score = "Sita", 91 print(f"{name} scored {score}")
Output
Hello world 3 4.5 True None a-b-c no new line ... continued Sita scored 91
Good to know. Use a comma (or an f-string) to print text and numbers together:
print("Age: " + 30) is a TypeError.Related
Learn it step by step in the free lesson Your First Program, with exercises that check your answers.