Accel Thinking

Python Learning Notes

print() Is More Than Hello World

A beginner-friendly Python note on using sep and end to control output formatting.

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:

Remember this sentence:

sep controls the middle. end controls the ending.

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

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

  1. Use sep="/" to output 2026/07/30 .
  2. Use two print() calls to output one line: Hello Python .
  3. Challenge: output A -> B -> C without using string concatenation.

One-Sentence Takeaway

sep controls what goes between values; end controls what comes after the printed line.