3 ms·
> The symantics of for...else are immediately obvious The code in your example is how it reads, but that's not how it works. The "obvious" reading is wrong, s
by Izkata 8y ago
> The symantics of for...else are immediately obvious
The code in your example is how it reads, but that's not how it works. The "obvious" reading is wrong, so it's obviously not "immediately obvious".
This is what it's actually doing:
found = False
for l in get_list():
if ...:
found = True
break
if not found:
...