If you are print multiple times then it will not print output in the same line in Python. Because print() function is used to print the output and By default, it jumps to the newline to printing the next statement.
See the below example.
print("Hello") print("world") print("!")
To print in the same line write a complete statement in a single print() function in Python.
print("Hello world !")
Output: Hello world !
Use end keyword
By adding the ‘ ‘ two single quotation marks you create the space between the two words, Hello and World, (Hello’ ‘World’) – I believe this is called a “blank string”.
print('Hello', end= ' ') print('World')
Output: Hello World
Print in the same line in for loop
The Python print() function has an argument called end, which prevents jump into the newline. Example use the end keyword in python. SAMPLE Of “end=” being used to remove the “newline” character.
list1 = [10, 11, 12, 13, 14, 15] for i in list1: print(i, end=" ")
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.