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?
for i in range(5): print(i, end=' ') print()
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
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
To print a range of numbers, you can do for i in range(5): print(i)