How to print without newline in Python

The python print()
function by default ends with a newline. Python has a predefined format if you use print(a_variable) then it will go to next line automatically.
To print without a newline in Python, checkout the below example:
# python code for # printing without # newline in python print("hello", end=" ") print("world") l = [1, 2, 3, 4] for i in l: print(i, end = " ")
Output:
hello world 1 2 3 4
Subscribe
Login
Please login to comment
0 Discussion