I understand how this construct works:
for i in range(10):
print(i)
if i == 9:
print(\"Too big - I\'m
I was just trying to make sense of it again myself. I found that the following helps!
• Think of the else
as being paired with the if
inside the loop (instead of with the for
) - if condition is met then break the loop, else do this - except it's one else
paired with multiple if
s!
• If no if
s were satisfied at all, then do the else
.
• The multiple if
s can also actually be thought of as if
-elif
s!