On Thu, 2 Nov 2017 10:45 pm, Alberto Berti wrote:
>>>>>> "Steve" == Steve D'Aprano <[email protected]> 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()
Have you tried it in the interactive interpreter?
py> for char in "abcdefgh":
... print(char, end='')
... print()
File "<stdin>", line 3
print()
^
SyntaxError: invalid syntax
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list