Le 31/08/2013 15:59, Peter Otten a écrit :


To make it crystal clear, the above was to illustrate the algorithm used in
Python 2, not a suggestion.


Ok sorry, I misinterpreted.




> I still think you should live with a trailing space


Are you sure ? The following code

#----------------------------------
import io

output = io.StringIO()
n=5
for i in range(n-1):
    print(i, end=' ', file=output)
print(n-1, file=output)
print(output.getvalue().count(' '))
#----------------------------------


outputs 4, the correct number of space character.



> or go with my actual
> suggestion
>
> print(*range(5))
>


It's a very good suggestion (the best one in fact) but rather complicated to explain to pure novices in programming.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to