Python Forum
Print in For Loop - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Print in For Loop (/thread-1173.html)



Print in For Loop - sajley - Dec-10-2016

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


RE: Print in For Loop - ichabod801 - Dec-10-2016

Using print(i), would work in Python 2.7. In Python 3.5, you would use print(i, end = ',').


RE: Print in For Loop - Yoriz - Dec-10-2016

for i in range(1, 9):
    print(i, end=' ')



RE: Print in For Loop - sajley - Dec-10-2016


Thank you for your answer.