The sep Argument
print('a', 'b') puts a space between the two. You have seen it a hundred times and probably took it for a rule of the language — it is not. It is a default you can change, and the argument that changes it is called sep, short for separator.
1The space was always a choice
When you write print(a, b, c), Python joins the three values with something before showing them, and that something is a single space unless you say otherwise. Saying otherwise looks like this:
# the space between the arguments is a choice, not a rule
print('LambdaLab', 'CS', 11)
print('LambdaLab', 'CS', 11, sep='')
print('LambdaLab', 'CS', 11, sep='-')
print('LambdaLab', 'CS', 11, sep=' | ')
print('2026', '08', '30', sep='/')LambdaLab CS 11 LambdaLabCS11 LambdaLab-CS-11 LambdaLab | CS | 11 2026/08/30
print('LambdaLab', 'CS', 11)No sep written, so the default is used: a single space. This is the line you have been writing all along.
sep=''Two quotes with nothing between them — the empty string. The values are pushed hard against each other with nothing in between.
sep='/'Anything you like goes in there, including several characters. The date program is the reason anybody learns this argument.
sep is written inside the brackets, after the values, with a comma before it. It is an argument to print(), exactly like the values are — but a named one, so its position does not matter and its name does. print('a', 'b', sep='-') prints two values with a dash between them; it does not print three things.2sep fills the gaps, and there is one fewer gap than values
This is the part that decides whether you can predict an output, and it is easier to see than to say. Three values have two gaps between them. So sep is used twice, not three times — and never at the beginning or the end:
# sep goes BETWEEN the arguments, never at the ends
print('a', 'b', 'c', sep='**')
print('only one argument', sep='**')
print('a', 'b', sep='\n')a**b**c only one argument a b
sep does nothing at all. One value has no gaps, so there is nowhere to put the separator. Nothing errors and nothing changes — which is exactly why print('Total: ' + str(t), sep=', ') confuses people: they gave print() one long value, not two.The third line is worth a second look. sep='\n' is the escape sequence for a newline, so the separator is a line break and one print() produces two lines. A separator does not have to be something you can see.
3Where the separator actually sits
Pick a separator below and watch which slots it fills. (Ignore end for now — that is the next page, and it is the reason the second line moves.)
sep fills the gaps between the arguments. end is added once, after the last one.
Three arguments make two gaps — one fewer than the arguments — and there is always exactly one ending.
LambdaLab CS 11 second line
The second print() starts on a new line, because end is still the newline nobody can see.
4When sep earns its keep
Nearly always when the pieces have to be joined by a punctuation mark rather than a space — a date, a time, a file path, a comma-separated line. The alternative is joining the pieces by hand with + and str(), and it is longer and easier to get wrong:
# the same date, printed two ways
day = 30
month = 8
year = 2026
print(str(day) + '/' + str(month) + '/' + str(year))
print(day, month, year, sep='/')30/8/2026 30/8/2026
sep does the str() for you. The first line needs three str() calls, because + refuses to join text to a number. print() converts everything it is given, so the second line needs none — which is one fewer thing to forget.5Recap
print(a, b) uses sep=' ' without being asked. Writing sep yourself replaces it — nothing else about print() changes.
n values means n − 1 separators. With a single value there are no gaps, so sep does nothing at all.
'', '-', ' | ', even '\n' for a line break. It is an ordinary string.
Unlike +, print() turns numbers into text itself, so sep needs no str() calls round the values.
What does print('a', 'b', 'c', sep='-') show?
What does print('hello', sep='***') show?
Why does print(day, month, year, sep='/') need no str() calls?