Skip to main content

/docs/images/banner.png

Python

Exception handling in Python

WAP to show the use of exception handling in python wit the help of try, except, else and finally block.

try:
a = 10
b = 0
c = a/b
print(c)
except ZeroDivisionError:
print("Division by zero is not allowed")
else:
print("Division is successful")
finally:
print("End of program")

# Output:
# Division by zero is not allowed
# End of program