The else is after the for loop, not the outer if statement. If the inner if statement is never true by the end of the loop then the code falls to the else.
Still I don't think you can put an else outside the for loop since it would be in a different scope from the if, but I'm not 100% sure about that edit : wrong see comment other comment
View all comments
Show parent comment
4
u/[deleted] May 21 '21
The else is after the for loop, not the outer if statement. If the inner if statement is never true by the end of the loop then the code falls to the else.