print function and unwanted trailing space
candide
candide at free.invalid
Sat Aug 31 05:25:31 EDT 2013
Le 31/08/2013 10:43, Andreas Perstinger a écrit :
> How about
>
> >>> print(" ".join(str(i) for i in range(5)))
> 0 1 2 3 4
>
Thanks for your answer. The output is stricly the same but the code
doesn't suit my needs :
1) I'm porting to Python 3 a Python 2 full beginner course : the
learners are not aware of the join method nor the str type nor
generators stuff;
2) Your code introduce a (sometimes) useless conversion to str (consider
a string instead of range(5)).
More information about the Python-list
mailing list