Skip to main content

Program to demonstrate the use if else block in Try Except block

· One min read
Kaustubh Kulkarni

Que > Program to demonstrate the use if else block in Try Except block

file.py
def divider(x, y):
try:
result = x // y
except ZeroDivisionError:
print("Error: dividing by zero ")
else:
print("Answer is :", result)
finally:
print('Program Terminated')
divider(3, 2)
Output
Answer is : 1
Program Terminated