Print Statements

The print() function writes text to the console.

Example

print("Hello, world!")
# outputs: Hello, world!

Common Patterns

Print variables

name = "Ari"
print("Hello,", name)
# outputs: Hello, Ari

Print multiple values

print("Apples", 3, "Bananas", 5)
# outputs: Apples 3 Bananas 5

Change the separator

print("1", "2", "3", sep=", ")
# outputs: 1, 2, 3

Change the ending

print("Loading", end="...")
print("done!")
# outputs: Loading...done!

Tip: the default end is a newline (\n). If you replace it, the next print() continues on the same line.