print function and unwanted trailing space

Andreas Perstinger andipersti at gmail.com
Sat Aug 31 04:43:55 EDT 2013


On 31.08.2013 10:17, candide wrote:
>
> What is the equivalent in Python 3 to the following Python 2 code:
>
> # -----------------------------
> for i in range(5):
>       print i,
> # -----------------------------
>
> ?

How about

 >>> print(" ".join(str(i) for i in range(5)))
0 1 2 3 4

Bye, Andreas






More information about the Python-list mailing list