डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Python Exception

Python exception is used to handle exception in a program, when we write a program it is good habit to write the code within try except block, using these blocks we can handle errors of program and error on program will not raise an error and rest of the code will run without any affect.
 
Example
try :
a=10
b=0
c=a/b
print(c)
except:
print("There is an error")
finally:
print("Program completed")
 

try

Write code or part of program here, in which exception may occur
 

except

This block will run when an exception occur
 

finally

This block will run always whatever an exception occur or not
© 2016 - 2023, All Rights are Reserved.