Many beginners first meet print() through print("Hello World"). That is a good starting point, but print() is more than a way to print one sentence. It is also one of the most useful tools for formatting output and debugging beginner programs.
This note focuses on two practical parameters: sep and end. Once you understand them, you can control what goes between printed values and what happens at the end of a printed line.
Common Mistake
Beginners often try to build formatted output with string concatenation:
print("CP" + " - " + "Club" + " - " + "Python")
This works, but it gets messy quickly. print() can already receive multiple values:
print("CP", "Club", "Python")
CP Club Python
By default, Python puts one space between the values.
Core Idea
Two print() parameters are especially useful for beginners:
sep: short for separator. It controls what goes between multiple values.end: it controls what comes after this print statement finishes.
Remember this sentence:
sep controls the middle. end controls the ending.
Recommended Pattern: Use sep for the Middle
If you want the values to be separated by - instead of spaces, write:
print("CP", "Club", "Python", sep=" - ")
CP - Club - Python
Here, sep=" - " means: put - between each pair of printed values.
Another example:
print("2026", "07", "30", sep="/")
2026/07/30
Recommended Pattern: Use end for the Ending
By default, every print() ends with a new line:
print("Hello")
print("Python")
Hello
Python
If you want the next output to continue on the same line, set end to a space:
print("Hello", end=" ")
print("Python")
Hello Python
Here, end=" " means: after printing Hello, do not move to a new line; add a space instead.
Comparison
| Code | Good for | Watch out |
|---|---|---|
print("A", "B") |
Printing multiple values | The default separator is one space |
print("A", "B", sep="-") |
Controlling the separator | sep only controls the middle |
print("A", end=" ") |
Controlling what happens after the line | end affects where the next output appears |
Why This Matters
In CCC and Python exercises, output format matters. One extra space or one missing newline can make the output look wrong.
Also, print() is one of the most useful debugging tools for beginners:
score = 87
print("score =", score)
score = 87
When you understand sep and end, your debugging output becomes much easier to read.
Practice
- Use
sep="/"to output2026/07/30. - Use two
print()calls to output one line:Hello Python. - Challenge: output
A -> B -> Cwithout using string concatenation.
One-Sentence Takeaway
sep controls what goes between values; end controls what comes after the printed line.
Questions or feedback?
Have a question about this article or want to suggest an improvement? Send us an email.
