How to print without newline in Python

2 Answers

0 votes
for i in range(1, 10 + 1):
    print(i, end=" ")

'''
run:

1 2 3 4 5 6 7 8 9 10 

'''

 



answered Feb 26, 2016 by avibootz
0 votes
import sys

for i in range(1, 10 + 1):
    sys.stdout.write(str(i) + " ")

'''
run:

1 2 3 4 5 6 7 8 9 10 

'''

 



answered Feb 26, 2016 by avibootz

Related questions

4 answers 431 views
1 answer 153 views
153 views asked Oct 12, 2022 by avibootz
1 answer 261 views
261 views asked Sep 19, 2020 by avibootz
1 answer 131 views
1 answer 171 views
...