I came across some code that has the structure:
for val in list:
do_something(val)
if val is x:
break
else:
do_something_else()
I couldn't find much information about this structure except that the else block won't be executed unless the for loop both executes, and finishes executing without hitting the break.
What would this be used for?
Is there a reason for it not being named something like 'finally', since that would seem to make more logical sense?
Thanks.