sep sets what goes between the objects passed to print(); end sets what goes after the last object. By default, Python separates objects with a space and ends each call with a newline.
What do sep and end do?
Python’s built-in function has the signature print(*objects, sep=' ', end='n', file=None, flush=False). It converts each object to text as str() does, joins the results with sep, then writes end after them. See the Python 3.13.16 built-in function reference.
As an Amazon Associate I earn from qualifying purchases.
| Argument | What it controls | Default |
|---|---|---|
sep |
Text between separate objects in the call | A single space |
end |
Text written after the final object | A newline (n) |
How do you change the separator?
Pass sep as a keyword argument to replace the default space between objects:
Recommended Free Tools
print("red", "green", "blue")
# red green blue
print("red", "green", "blue", sep=", ")
# red, green, blue
The separator applies only between distinct objects passed to the call. It does not edit the contents of a string:
#1 Best Overall
print("a", "b", sep="/")
# a/b
print("a b", sep="/")
# a b
In the second call, "a b" is one object, so there is no boundary for sep to replace.
How do you change what comes after the output?
By default, a call ends with a newline, so the next printed text starts on a new line. Set end to another string to replace that newline:
Rank #2
print("Loading", end="...")
print(" done")
# Loading... done
Setting end="" adds no text after the output, so the next call continues immediately:
print("Hello", end="")
print(" there")
# Hello there
end changes only the ending; it does not remove the text printed by the call.
Can sep or end be None?
Yes. Either argument can be None, which tells print() to use that argument’s default: a space for sep or a newline for end. Otherwise, both arguments must be strings.
What happens when you call print() with no objects?
With no objects, print() writes only its end value. Because the default ending is a newline, an empty print() call normally creates a blank line. If you supply a different ending, it writes that string instead.
Where does print() write?
Unless you pass a file argument, print() writes to sys.stdout. A supplied file object must have a write(string) method; print() writes text, not binary data. The optional flush=True argument forces the stream to flush; otherwise, buffering is generally determined by the stream.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsWhen should you use a different formatting method?
sep and end control the boundaries around printed objects, not the construction of complex text. For formatted text with values embedded in a sentence, an f-string is often clearer. Python’s informal introduction and input and output tutorial explain string formatting and output behavior. Special characters such as n in printed text are rendered as line breaks.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




