>>>>> "Steve" == Steve D'Aprano <steve+pyt...@pearwood.info> writes:

    py> for x in "abcdefgh":
    Steve> ...     print(x, end='')
    Steve> ...
    py> efghpy>


    Steve> "For ... else" to the rescue!

    py> for char in "abcdefgh":
    Steve> ...     print(char, end='')
    Steve> ... else:
    Steve> ...     print()
    Steve> ...
    Steve> abcdefgh
    py> 

else doesn't seem to bring any advantage over:

for char in "abcdefgh":
    print(char, end='')
print()

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

Reply via email to