Python Forum

Full Version: Print in For Loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
for i in range(1,9):
   print(i)
result:
Output:
1 2 3 4 5 6 7 8
how i can print this result:
Output:
1 2 3 4 5 6 7 8 
* print numbers in one line.
* i use camma ',' in end of print but not work.  -->  
print(i),
  Think
Using print(i), would work in Python 2.7. In Python 3.5, you would use print(i, end = ',').
for i in range(1, 9):
    print(i, end=' ')

Thank you for your answer.