Syntax
print(*values, sep=" ", end="\n")Examples
Basic Output
Printing simple values and multiple items in a single call.
print("Hello, World!")
print(42)
print("Score:", 95, "out of", 100)Custom Separator
Using the 'sep' argument to control how multiple values are joined.
print("2026", "08", "08", sep="-") # 2026-08-08
print("a", "b", "c", sep=", ") # a, b, cCustom End Character
Using the 'end' argument to avoid the default newline, useful for progress indicators.
print("Loading", end="")
for _ in range(3):
print(".", end="")
print() # move to a new line afterward
# Output: Loading...Printing with f-strings
Combining print() with formatted string literals for readable output.
name = "Fola"
score = 87
print(f"{name} scored {score}%")Best practices
- Use f-strings inside print() for readable, dynamic output rather than string concatenation with +
- Use print() for quick debugging, but prefer Python's logging module for anything in a real application that needs log levels or timestamps
- Remember print() always adds a newline by default - override with end='' when you need to build output incrementally
- Pass multiple arguments directly to print() instead of manually concatenating them with str()
- Avoid leaving stray debug print() statements in production code - remove or replace them with proper logging
At a glance
- Purpose
- Scripting and general-purpose applications
- File extension
- .py
- Runs in
- Python interpreter
- Usually used with
- Python standard library and packages
Specifications & further reading
Related Python documentation
True
In Python, True is a built-in constant that represents the boolean value of true. Alongside False, True enables logical and conditional operations. It's a fundamental keyword used throughout Python programming for decision-making, loops, comparisons, and boolean logic. True plays a key role in if statements, while loops, and logical expressions.False
False is Python's built-in constant representing the boolean value false. It's the logical opposite of True and is essential for conditional logic, loop control, and boolean operations. False is used to indicate negative conditions, failed validations, or when something is not the case. Understanding False is crucial for writing effective control flow in Python programs.None
None is Python's built-in singleton value that represents the absence of a value or a null result. It is its own type (NoneType) and is commonly used as a default parameter value, a placeholder before a variable is assigned real data, or a function's implicit return value when nothing is explicitly returned. Unlike 0, an empty string, or an empty list, None specifically means 'no value here', not 'an empty value'.Variables & Assignment
Variables in Python are names bound to values, created the moment you first assign to them - there's no need to declare a type in advance, since Python is dynamically typed. A single variable can be reassigned to a completely different type later in the program. Python also supports several convenient assignment patterns, including assigning multiple variables at once and using augmented assignment operators.
In Python, True is a built-in constant that represents the boolean value of true. Alongside False, True enables logical and conditional operations. It's a fundamental keyword used throughout Python programming for decision-making, loops, comparisons, and boolean logic. True plays a key role in if statements, while loops, and logical expressions.False
False is Python's built-in constant representing the boolean value false. It's the logical opposite of True and is essential for conditional logic, loop control, and boolean operations. False is used to indicate negative conditions, failed validations, or when something is not the case. Understanding False is crucial for writing effective control flow in Python programs.None
None is Python's built-in singleton value that represents the absence of a value or a null result. It is its own type (NoneType) and is commonly used as a default parameter value, a placeholder before a variable is assigned real data, or a function's implicit return value when nothing is explicitly returned. Unlike 0, an empty string, or an empty list, None specifically means 'no value here', not 'an empty value'.Variables & Assignment
Variables in Python are names bound to values, created the moment you first assign to them - there's no need to declare a type in advance, since Python is dynamically typed. A single variable can be reassigned to a completely different type later in the program. Python also supports several convenient assignment patterns, including assigning multiple variables at once and using augmented assignment operators.