for else


The else statement of the for loop is executed when the iteration ends normally. (without calling break)


examples/advanced/for_else.py
names = ['Foo', 'Bar', 'Baz']


for i in range(3):
    name = input('Your name please: ')
    if name in names:
        break
else:
    print("Not OK")
    exit()

print("OK....")