Print new output on same line

Viewed 422742

I want to print the looped output to the screen on the same line.

How do I this in the simplest way for Python 3.x

I know this question has been asked for Python 2.7 by using a comma at the end of the line i.e. print I, but I can't find a solution for Python 3.x.

i = 0 
while i <10:
     i += 1 
     ## print (i) # python 2.7 would be print i,
     print (i) # python 2.7 would be 'print i,'

Screen output.

1
2
3
4
5
6
7
8
9
10

What I want to print is:

12345678910

New readers visit this link aswell http://docs.python.org/release/3.0.1/whatsnew/3.0.html

7 Answers
print("single",end=" ")
print("line")

this will give output

single line

for the question asked use

i = 0 
while i <10:
     i += 1 
     print (i,end="")
Related