Python 3 crumbs tagged with #else

Your for-loop might be missing an else block

Your for-loop might be missing an else block

Aug 30, 2022 by erik

There's a little-known construct in Python that can be quite useful: using else in combination with loops. That's right, for-loops and while-loops can be followed by an else block! Let's look at how you can use the else block in...

else for-loop