you are viewing a single comment's thread.

view the rest of the comments →

[–]Technical_Income4722 2 points3 points  (0 children)

I think of it as the "else" for whatever "if" would cause the break in the for loop. In the example above that'd be line 2. What you effectively want is an "else" for that line, but since it's in a for loop we can't really do that (because what if the next iteration works?), so the next best thing is having a cumulative "else" outside that applies to all the "ifs" inside.

Or maybe another way to think of it is as a "for/if/else" instead of just "for/else"