How to print without a Newline in Python?

In Python whenever you print any statement, a newline is added by default. And, people coming from other languages find it weird and want to know how to avoid this newline. This happens because in Python, Newline is added as a default parameter to print() function. Let’s see some examples below and how can we use print function without newline being added to it.

#Python 3.X
#Using print function in Python
print("Outshine Labs")
Print("Python Rocks")

#Default Output of print function
Outshine Labs
Python Rocks

Now if you want to use the print function without printing unnecessary newline, you can pass space as the “end” parameter. An example is given below. This solution depends on the python version you are using and works with Python 3. It is recommended that you read more about print functions using the link above.

#Python 3.X
#Using print function without newline in Python
print("Outshine Labs", end=" ")
Print("Python Rocks", end=" ")

#Output of print function with custom end parameter
Outshine Labs Python Rocks
Share this