0

I have a script that creates a lot of output. Is there any way to create that in the same line?

For example

i, I = 0, 4
while i < I:
    i+=1
    print i

would print something like

1
2
3
4

How would I adjust it to print?

1 2 3 4 

Obviously, the print commands have to be split up, otherwise the question is trivial.

FooBar
  • 15,724
  • 19
  • 82
  • 171

1 Answers1

1

Change print i to print i,:

i, I = 0, 4
while i < I:
    i+=1
    print i,

This prints it on the same line.

Leigh
  • 12,038
  • 4
  • 28
  • 36