print() in Depth
Everything print() can do — printing multiple values, controlling separators, end characters, and formatting output beautifully.
"You have used print() since lesson one. Now it is time to see everything it can actually do."
— ShurAIprint() — The Basics Refresher
print() sends output to the terminal. You already know the basics — but print() has several powerful optional parameters that most beginners never discover. Once you know them, you will use them constantly.
# The basics — you know these
print("Hello, World!")
print(42)
print(3.14)
print(True)
# Empty print — prints a blank line
print()
Printing Multiple Values at Once
You can pass multiple values separated by commas. Python prints them all on one line with a space between each:
name = "Riya"
age = 22
city = "Pune"
# Multiple values — auto space between them
print(name, age, city)
# Riya 22 Pune
# Mix types freely — no str() conversion needed
print("Name:", name, "| Age:", age)
# Name: Riya | Age: 22
The sep Parameter — Custom Separator
By default, print puts a space between multiple values. The sep parameter lets you change that separator to anything you want:
# sep="" — no space between values
print("Hello", "World", sep="")
# HelloWorld
# sep=", " — comma and space
print("apple", "banana", "mango", sep=", ")
# apple, banana, mango
# sep=" | " — pipe separator
print("Name", "Age", "City", sep=" | ")
# Name | Age | City
# sep="\n" — each value on its own line
print("Line 1", "Line 2", "Line 3", sep="\n")
# Line 1
# Line 2
# Line 3
# Build a date without concatenation
print(2026, 12, 25, sep="-")
# 2026-12-25
The end Parameter — What Comes After
By default, print() adds a newline \n at the end — that is why each print starts on a new line. The end parameter lets you change or remove this:
# Default — each print on new line (end="\n" by default)
print("First")
print("Second")
# First
# Second
# end=" " — stay on same line, add space
print("Hello", end=" ")
print("World")
# Hello World
# end="" — no gap at all between prints
print("Loading", end="")
print("...", end="")
print(" Done")
# Loading... Done
# end="!" — custom ending character
print("Great job", end="!\n")
# Great job!
Combining sep and end Together
# Build a progress bar feel
print("Step 1", "Step 2", "Step 3", sep=" → ", end=" ✓\n")
# Step 1 → Step 2 → Step 3 ✓
# Print items from a loop on one line
for i in range(1, 6):
print(i, end=" ")
# 1 2 3 4 5
Printing to a File
The file parameter redirects output to a file instead of the screen. You will use this when building tools that write logs or reports:
# Write directly to a file using print
with open("log.txt", "w") as f:
print("Server started", file=f)
print("User logged in", file=f)
print("Request processed", file=f)
# log.txt will contain:
# Server started
# User logged in
# Request processed
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
The asterisk *objects means you can pass any number of values. The defaults explain the familiar behaviour: space between values, newline at the end, output to screen.
Real Example — Formatted Table
Using sep, end, and f-strings together to build a clean table without any extra libraries:
students = [
("Riya", 92),
("Arjun", 85),
("Sneha", 78),
("Vikram", 95),
]
print("=" * 25)
print(f"{'Name':10} {'Score':8} {'Grade'}")
print("-" * 25)
for name, score in students:
grade = "A" if score >= 90 else "B" if score >= 80 else "C"
print(f"{name:10} {score:8} {grade}")
print("=" * 25)
=========================
Name Score Grade
-------------------------
Riya 92 A
Arjun 85 B
Sneha 78 C
Vikram 95 A
=========================
"print() looks simple. But once you know sep and end, you have fine-grained control over every character your program puts on screen."
— ShurAI🧠 Quiz — Question 1
What does print("a", "b", "c", sep="-") output?
🧠 Quiz — Question 2
What is the default value of the end parameter in print()?
🧠 Quiz — Question 3
What does print("Hi", end="") followed by print("Bye") output?
🧠 Quiz — Question 4
What does a bare print() with no arguments output?