0

Python printing help

What is the cleanest and most painless way to print or return something - a range for example - on the same line, instead of one by one line?

19th Oct 2019, 12:59 AM
MRJN
MRJN - avatar
4 odpowiedzi
+ 3
for i in range(5): print(i, end=' ') print()
19th Oct 2019, 1:53 AM
rodwynnejones
rodwynnejones - avatar
+ 1
Oh, sorry. I didn't understand. I think you might be looking for something like: s = "" for i in range(5): s += str(i) + " " print(s) # 0 1 2 3 4 You could also do something like this: print(list(range(5))) # [0, 1, 2, 3, 4,] Which prints the range as a list representation
19th Oct 2019, 1:20 AM
Brian R
Brian R - avatar
0
No, like I said I do not want to print them line by line. I want to print the range all in the same line, and then move on to the next line. I do not want this: https://code.sololearn.com/ck085IsBZ3v2/?ref=app
19th Oct 2019, 1:17 AM
MRJN
MRJN - avatar
- 1
To print a range of numbers, you can do for i in range(5): print(i)
19th Oct 2019, 1:02 AM
Brian R
Brian R - avatar