Python | Print in the same line
Python print() function default ends with a newline. Python has a predefined format when you use print(variable) then it will automatically go to next line.
Example 1:
print("i2tutorials") print("Python")
Output:
Example 2:
a = [1, 2, 3, 4] # printing a element for i in range(4): print(a[i])
Output:
Below example shows how to print result on the same line.
Example:
print("i2tutorials", end =" ") print("Python") # array a = [1, 2, 3, 4] # printing a element in same # line for i in range(4): print(a[i], end =" ")
Output:
Share: