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
  • 14,654
  • 17
  • 73
  • 157

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
  • 11,344
  • 4
  • 27
  • 35