You can download this code by clicking the button below.
This code is now available for download.
Define a function that attempts to perform division. If the divisor is zero, it catches the exception and returns an error message.
Technology Stack : Exception handling (try-except)
Code Type : Exception handling
Code Difficulty : Intermediate
def aaaaaa(arg1, arg2):
try:
return arg1 / arg2
except ZeroDivisionError:
return "Cannot divide by zero"