Re: Hack or beauty?

Ethan Furman <[email protected]> Thu, 14 May 2026 10:16:15 -0700
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
On 5/14/26 01:32, Left Right via Python-list wrote:

 > [...] "else" is
 > allowed in "strange" places in Python, eg.
 >
 >      for var in iterator:
 >      else:
 >          statement
 >
 > with the intention of executing the "statement" when the loop exits
 > early.

Not sure what you mean by "exits early", but the `else` statement will run unless `break`
is encountered in the `for` loop.

--
~Ethan~