Le 31/08/2013 12:31, Peter Otten a écrit : > softspace = False > for i in range(5): > if softspace: > print(end=" ") > print(i, end="") > softspace = True > print()
The if instruction imposes useless testing (we know in advance the problem to occur at the very end of the loop) and useless writing (writing '').
The following is clearer # ------------------------- n=5 for i in range(n-1): print(i, end=' ') print(n-1) # ------------------------- but doesn't solve all the cases (imagine a string or an iterator). -- http://mail.python.org/mailman/listinfo/python-list