Python Exception Handling
Process of responding to the occurence during computation of exceptional condition requiring special processing ofrtn changing the normal flow of program execution.
Python Exception
An exception is an event which occurs during the execution of a program that disrupts the normal flow of the program's instruction.
Important Terms:
try:
Uesd to keep the code segment under check.except:
Segment to handle the exception after catching it.else:
Run this when no exception exist.finally:
No matter what runs this coded if/if not for exception.
Example
try: numerator = 10 denominator = 0 result = numerator/denominator print(result) except: print ("Error: Denominator cannot be 0.") Output Error: Denominator cannot be 0.