Mar-04-2017, 01:15 AM
I've read so much about try and exception but none tell how to exit the program gracefully and not continue the rest of the code. For example:
Alternatively, is there a way to jump to a different label in the program to continue execution on a different path like in Basic?
Newbie learning Python 3.6
try: result = x / y except ZeroDivisionError: print "division by zero!" (How do I exit the program from here?) (Alternatively, how do I continue the program on a different path from here?) else: print "result is", result (continue normal execution from here)So if there is a divide by zero error, how does one exit the program from that point?
Alternatively, is there a way to jump to a different label in the program to continue execution on a different path like in Basic?
Newbie learning Python 3.6