Write a function to compute 5/0 and use try/except to catch the exceptions.


Topic: Write a function to compute 5/0 and use try/except to catch the exceptions.

Solution

def throws():
return 5/0
try:
throws()
except ZeroDivisionError:
print ("division by zero!")
except Exception, err:
print ('Caught an exception')
finally:
print ('In finally block for cleanup')



List all Python Programs