In Python 3, you can use the sep= and end= parameters of the print function:

To not add a newline to the end of the string:

print('.', end='')

To not add a space between all the function arguments you want to print:

print('a', 'b', 'c', sep='')

You can pass any string to either parameter, and you can use both parameters at the same time.

If you are having trouble with buffering, you can flush the output by adding flush=True keyword argument:

print('.', end='', flush=True)

Python 2.6 and 2.7

From Python 2.6 you can either import the print function from Python 3 using the __future__ module:

from __future__ import print_function

which allows you to use the Python 3 solution above.

However, note that the flush keyword is not available in the version of the print function imported from __future__ in Python 2; it only works in Python 3, more specifically 3.3 and later. In earlier versions you'll still need to flush manually with a call to sys.stdout.flush(). You'll also have to rewrite all other print statements in the file where you do this import.

Or you can use sys.stdout.write()

import sys
sys.stdout.write('.')

You may also need to call

sys.stdout.flush()

to ensure stdout is flushed immediately.

Answer from codelogic on Stack Overflow
Top answer
1 of 16
3436

In Python 3, you can use the sep= and end= parameters of the print function:

To not add a newline to the end of the string:

print('.', end='')

To not add a space between all the function arguments you want to print:

print('a', 'b', 'c', sep='')

You can pass any string to either parameter, and you can use both parameters at the same time.

If you are having trouble with buffering, you can flush the output by adding flush=True keyword argument:

print('.', end='', flush=True)

Python 2.6 and 2.7

From Python 2.6 you can either import the print function from Python 3 using the __future__ module:

from __future__ import print_function

which allows you to use the Python 3 solution above.

However, note that the flush keyword is not available in the version of the print function imported from __future__ in Python 2; it only works in Python 3, more specifically 3.3 and later. In earlier versions you'll still need to flush manually with a call to sys.stdout.flush(). You'll also have to rewrite all other print statements in the file where you do this import.

Or you can use sys.stdout.write()

import sys
sys.stdout.write('.')

You may also need to call

sys.stdout.flush()

to ensure stdout is flushed immediately.

2 of 16
303

For Python 2 and earlier, it should be as simple as described in Re: How does one print without a CR? by Guido van Rossum (paraphrased):

Is it possible to print something, but not automatically have a carriage return appended to it?

Yes, append a comma after the last argument to print. For instance, this loop prints the numbers 0..9 on a line separated by spaces. Note the parameterless "print" that adds the final newline:

>>> for i in range(10):
...     print i,
... else:
...     print
...
0 1 2 3 4 5 6 7 8 9
>>>
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-print-without-new-line
Python Print Without New Line: What You Need to Know | DataCamp
August 22, 2024 - In Python 2, the print statement is different and adds a new line by default. You can add a comma at the end of the print statement to print without a new line. # Print without newline print "Hello", print "World"
Discussions

How do I print \n without making a new line?
print("hello \\n this should not be a new line") More on reddit.com
๐ŸŒ r/learnpython
32
24
February 4, 2022
How to print without a newline or space
How can you print output in Python without adding a newline or space? What techniques let you control exactly how text appears on the same line? More on janbasktraining.com
๐ŸŒ janbasktraining.com
1
May 21, 2025
can you print '\n' in python?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/learnprogramming
26
8
July 11, 2023
\n giving me an extra space on new line?
Yeah learn f-strings. For this particular problem though I'd just use two print statements for readability. Python print has an optional separator keyword argument (sep = ' ') but it will use it on all values separated by commas. The default is sep = ' ', not sep = ''. print(1, 2, 3) -> 1 2 3 print(1, 2, 3, sep = '') -> 123 print(1, 2, 3, sep = '*') -> 1*2*3 Edit: It's always worth checking out the documentation, it's a good habit. https://docs.python.org/3/library/functions.html#print More on reddit.com
๐ŸŒ r/learnpython
29
53
April 26, 2023
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ print-without-newline-python
How to Print without newline in Python? - GeeksforGeeks
In Python, you can use the asterisk (*) operator to unpack a list or tuple and print its elements without adding a newline between them.
Published: April 26, 2025
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ python-print-without-newline
Python: How to Print without newline (3 Methods)
September 11, 2024 - The end parameter's default value is the newline character, or '\n'. To print without a newline character, we can set it to either the empty string or any other character/string.
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ python print without newline: step-by-step guide
Python Print Without Newline: Step-by-Step Guide | Career Karma
December 1, 2023 - Printing without a new line is simple in Python 3. In order to print without newline in Python, you need to add an extra argument to your print function that will tell the program that you donโ€™t want your next string to be on a new line.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how do i print \n without making a new line?
r/learnpython on Reddit: How do I print \n without making a new line?
February 4, 2022 -

Hello!

Im looking for a way to print \n without making a new line, for example:

If I try to do

Print('hello \n this should not be a new line')

the output would be :

hello

this should not be a new line

Even though I want it to be:

hello \n this should not be a new line

Sorry if this is really simple, ive tried searching everywhere and theres nothing about it, only stuff about quotes which I cant find out how to apply to \n

Thank you in advance

๐ŸŒ
JanBask Training
janbasktraining.com โ€บ community โ€บ python โ€บ how to print without a newline or space
How to print without a newline or space | JanBask Training Community
May 21, 2025 - Use end="" to avoid newlines after print. Use sep="" to avoid spaces between multiple arguments. This lets you customize how your output appears, especially useful for progress bars, inline messages, or formatting.
Find elsewhere
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ python-print-without-newline
[SOLVED] Python Print Without Newline? Syntax and Examples
February 14, 2024 - However, you can modify this behavior with the โ€˜endโ€™ parameter. If you want to print without a newline, use an empty string with the โ€˜endโ€™ parameter. For instance print('Hello, World!', end='').
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ python โ€บ python new line: how to print without newline in python
Python New Line: How to Print WITHOUT Newline in Python
July 10, 2026 - In Python 3, pass end=โ€ to print(), like print(text, end=โ€). This stops the default newline. ... Set end to a space: print(text, end=โ€™ โ€˜). Any string given to end separates items instead of a line break.
๐ŸŒ
Afternerd
afternerd.com โ€บ blog โ€บ how-to-print-without-a-newline-in-python
Python: How to Print Without Newline? (The Idiomatic Way) - Afternerd
January 13, 2019 - ... import sys sys.stdout.write("Hello ... Karim ยท In Python 3, you can use the named end argument in the print function and assign an empty string to this argument to prevent the terminating newline....
๐ŸŒ
STechies
stechies.com โ€บ python-print-without-newline
Python: How to Print Without Newline?
January 8, 2024 - F-strings render a more concise and convenient way to print without newline characters in Python since it has embedded Python expressions inside string literals to format.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ python-how-to-print-without-newline-or-space
Python: How to Print without Newline or Space
March 13, 2023 - The other arguments include a separator ... to the next line. In Python 3.x, the most straightforward way to print without a newline is to set the end argument as an empty string i.e....
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ python-print-without-newline
Python: Print without Newline
July 9, 2020 - For Python 2.x, we can simply add a comma after the print function call, which will terminate the printed string with a space instead of a newline character:
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-print-without-newline-solved
Python Print Without Newline [SOLVED]
May 10, 2022 - If you're familiar with Python, you may have noticed that the built-in function print() doesn't need an explicit \n character at the end of each line. This means that the output from the following snippet of code print('freeCodeCamp Curriculum') ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-new-line-and-how-to-python-print-without-a-newline
Python New Line and How to Python Print Without a Newline
June 20, 2020 - The new line character in Python is \n. It is used to indicate the end of a line of text. You can print strings without adding a new line with end = <character>, which <character> is the character that will be used to separate the lines.
๐ŸŒ
Raspberry Pi Forums
forums.raspberrypi.com โ€บ board index โ€บ programming โ€บ python
How to print without newline - Raspberry Pi Forums
for python 3 its like: print("My 1st String", end=","); print ("My 2nd String.") whilst in python 2 its: print "My 1st String,", print "My 2nd String" ... Old: print x, # Trailing comma suppresses newline Python 3.x: print(x, end=" ") # Appends a space instead of a newline Note that the trailing ...
๐ŸŒ
Bacancy Technology
bacancytechnology.com โ€บ qanda โ€บ python โ€บ print-without-a-newline-or-space
How to Print Without a Newline or Space: Detailed Guide
March 19, 2024 - # Using the 'end' parameter in the 'print' function print("This is printed without a newline", end="") print(" and continues on the same line.") # Using 'sys.stdout.write' import sys sys.stdout.write("This is printed without a newline") ...
๐ŸŒ
www.game-u.com
game-u.com โ€บ news-and-blog โ€บ python-print-new-line
Python Print New Line: Easy Ways Add Line Breaks in Python
May 25, 2026 - To avoid a newline, use print(..., end=""). When you want to format text output in Python, knowing how to give next line in Python in print is essential โ€” one of the first skills covered in our kids coding basics resources.
๐ŸŒ
PythonHow
pythonhow.com โ€บ how โ€บ print-without-a-newline-or-space-in-python
Here is how to print without a newline or space in Python
New: Practice Python, JavaScript & SQL with AI feedback โ€” Try ActiveSkill free โ†’ ร— ... To print without a newline or space in Python, you can use the end parameter of the print() function.
๐ŸŒ
Intellipaat
intellipaat.com โ€บ home โ€บ blog โ€บ how to print without newline or space in python
How to Print Without Newline or Space in Python (With Examples)
October 17, 2025 - Explanation: Here, the list comprehension iterates over numbers and prints each element without a newline. However, it is not the most readable approach. This demonstrates Python print without newline in for loop using list comprehension.