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 416 views
1 answer 147 views
147 views asked Oct 12, 2022 by avibootz
1 answer 251 views
251 views asked Sep 19, 2020 by avibootz
1 answer 122 views
1 answer 160 views
...