print() is the most common way to produce output in Python — it converts its arguments to text and writes them to the screen, automatically separating multiple arguments with a space and ending with a line break. Both of those defaults can be changed with the sep and end keyword arguments.
#how it works
1
print() accepts any number of values
Separated by commas, in a single call.
2
Values are joined with a space by default
Controlled by the sep argument.
3
A line break is added at the end by default
Controlled by the end argument — this is why consecutive print() calls land on separate lines.
4
sep can be changed
Any string works, like a hyphen or an empty string.
5
end can be changed too
Setting end to a space, for example, keeps the next print() on the same line instead of starting a new one.
#example
print("A", "B", "C")
print("A", "B", "C", sep="-")
print("No newline", end=" ")
print("right after")
Output
A B C
A-B-C
No newline right after
1print("A", "B", "C") joins the three values with the default single-space separator.
2Adding sep="-" changes the separator to a hyphen instead of a space.
3end=" " on the third call replaces the default line break with a single space, so the next print() lands on the same line rather than starting a new one.
4print("right after") then adds its own default line break at the very end.
#use cases
Debugging by quickly printing variable values to check what's happening in a program
Formatting simple console output, like a table of results with a custom separator
Building progress indicators or single-line status updates using end=""
Displaying results at the end of a script
Practice Python interview questions
Every Python lesson maps to the matching interview topic, with answers written for current Python versions.
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses →Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free →Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books →