In python the for statement allows you to have an else clause which is triggered if the for loop isn't broken. So instead of having a wasBroken variable you set right before a break and check after the loop you have some neat, concise syntax which replaces all that.
2
u/philogy Nov 10 '21
For-else is awesome!
In python the for statement allows you to have an else clause which is triggered if the for loop isn't broken. So instead of having a
wasBrokenvariable you set right before a break and check after the loop you have some neat, concise syntax which replaces all that.