tags:

views:

43

answers:

1

In Python 2.x, I'd write...

for i in range(5):
    print i,

...to get integers from 0 to 4 printed in the same row. How to do that in Python 3.x, since print is a function now?

+7  A: 

Use print(x, end = ' '):

From the release notes:

Old: print x,           # Trailing comma suppresses newline  
New: print(x, end=" ")  # Appends a space instead of a newline
Mark Byers