I accidently used 'exit' in a loop where I meant to use 'break' and, in that
case, the program seemed to work as expected but in some cases 'exit' seems
to behave differently from 'break'. For example, in this code snippet using
'exit' or 'break' produces the same result:

for i in range(10):
    if i > 3:
        exit
    else:
        print(i)
print('out of loop')

But in this case they behave differently:

for i in range(10):
    if i > 3:
        break   # try using exit here.
    else:
        print(i)
else:
    print('for loop else statement')

print('out of loop')

Does anyone have any pointers to descriptions of 'exit', what it is, what it
means, how It's used, etc.?


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to