Python print() function is used to display the content in the console but multiple print() will go to the next line automatically. You have to use an additional parameter introduced for print() called end= to print without newline in Python.
This parameter takes care of removing the newline that is added by default in print(). The value of
end and set it to
Python print without newline
Simple example code.
print("Python print", end=" ") print("without newline")
Printing a list element in the same line
a = [1, 2, 3, 4, 5] for i in range(5): print(a[i], end=" ")
Output: 1 2 3 4 5
Print without newline and for loop
l=[1,2,3,4,5,6] # using * symbol prints the list # elements in a single line print(*l)
Output: 1 2 3 4 5 6
Do comment if you have any doubts or suggestions on this Python print topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.