A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

Peter Otten __peter__ at web.de
Fri Feb 24 08:14:12 EST 2012


Peter Otten wrote:

> The code in the else suite executes only when the for loop is left via
> break. 

Oops, the following statement is nonsense:

> A non-empty iterable is required but not sufficient.

Let me try again:

A non-empty iterable is required but not sufficient to *skip* the else-suite 
of a for loop.




More information about the Python-list mailing list