The print() method in Python automatically prints in the next line each time. The print() method by default takes the pointer to the next line.
for i in range(5): print(i)
0 1 2 3 4
The print method takes an extra parameter end=” “ to keep the pointer on the same line.
The end parameter can take certain values such as a space or some sign in the double quotes to separate the elements printed in the same line.
print(“…..” , end=” “)
The end=” “ is used to print in the same line with space after each element. It prints a space after each element in the same line.
for i in range(5): print(i,end=" ")
0 1 2 3 4
The end=”” is used to print on same line without space. Keeping the doube quotes empty merge all the elements together in the same line.
for i in range(5): print(i,end="")
The end=”,” is used to print in the same line with a comma after each element. We can use some other sign such as ‘.’ or ‘;’ inside the end parameter.
for i in range(5): print(i,end=",") print(i,end=".")