If you need Python print without newline behavior, use the end argument of the Python 3 print() function. By default, print() adds a newline after every call. Changing end lets the next value stay on the same line, which is useful for progress messages, compact loop output, and command-line prompts.
Quick answer: use end=””
The shortest fix is to pass an empty string to end. The next print() call will continue from the same cursor position instead of starting a new line.
print("Python", end="")
print("Pool")
Output:
PythonPool
The default value is similar to end="\n". When you replace that newline with "", Python writes the text and stops there. If you want a space between values, use end=" " instead of an empty string.
print("Python", end=" ")
print("Pool")
Output:
Python Pool
Use sep and end together
The sep argument controls what appears between multiple values in one print() call. The end argument controls what appears after the call. They solve different parts of the output format, and using both is often cleaner than building a string by hand.
print("A", "B", "C", sep="-", end="!")
Output:
A-B-C!
This is useful when printing IDs, counters, paths, or small status strings. If your output is part of a larger function, also compare this behavior with print vs return in Python, because printing to the terminal is not the same thing as returning a value to the caller.
Print loop output on one line
A common use case is printing values from a loop without creating a new line for every iteration. Put the separator you want inside end.
for number in range(3):
print(number, end=" ")
Output:
0 1 2
The final space is expected because each call writes one after the number. If you need a perfectly formatted string without trailing spaces, collect values and join them, or use formatting that matches the final output exactly. For line-oriented input and output workflows, see reading a file line by line in Python and reading input from stdin.
Use flush for progress output
Some terminals and environments buffer output. That means a message printed without a newline may not appear immediately. Add flush=True when the user should see the update right away.
print("Loading", end="...", flush=True)
For a single-line status display, you can use a carriage return. The \r character moves the cursor back to the start of the same line, letting the next message overwrite the old one in many terminals.
print("Progress: 10%", end="\r", flush=True)
print("Progress: 20%", end="\r", flush=True)
This pattern is helpful for small command-line tools. For long-running or production-grade progress bars, a dedicated progress library is usually easier to maintain. For simple scripts, end="\r" and flush=True are enough.
Write directly with sys.stdout.write()
The print() function is convenient because it converts values to strings, inserts separators, and adds the final end value. If you only want to write an exact string, sys.stdout.write() is another option.
import sys
sys.stdout.write("Python")
sys.stdout.write("Pool\n")
Output:
PythonPool
Use print() when you want readable formatting with sep, end, and flush. Use sys.stdout.write() when you want lower-level control and you already have the exact string. If you are dealing with text cleanup after output is generated, removing newline characters from a Python list covers the opposite problem.
Test output without writing to the terminal
For tests, pass a file-like object to print(). io.StringIO captures output in memory, so you can assert exactly what was printed.
from io import StringIO
buffer = StringIO()
print("Python", end="", file=buffer)
print("Pool", file=buffer)
assert buffer.getvalue() == "PythonPool\n"
This is a clean way to test formatting without depending on the real terminal. It also makes examples easier to verify because the expected newline is visible in the assertion.
Common mistakes
Use the Python 3 function form: print("text", end=""). Python 2 style print statements are obsolete, and Python 2 is no longer supported for new code. If you are maintaining old tutorials or scripts, modernize the examples before copying them into a Python 3 project. The same applies to old input examples; the difference is covered in Python input vs raw_input.
Another mistake is expecting end="" to remove newlines already present inside the string. It only changes what print() appends after the value. If the string itself contains \n, that newline still prints.
print("Python\nPool", end="")
Output:
Python
Pool
When you need compact output from a loop, decide whether you want a trailing separator. When you need instant terminal feedback, add flush=True. When you need exact low-level output, use sys.stdout.write(). Those choices cover most cases where you want to print without creating a new line.