You can download this code by clicking the button below.
This code is now available for download.
Defined a simple division function that returns an error message if the second argument is zero.
Technology Stack : None, try-except, ValueError, ZeroDivisionError
Code Type : Mathematical operation function
Code Difficulty :
def a_func(arg1, arg2):
try:
if arg1 is None or arg2 is None:
raise ValueError("Arguments cannot be None")
result = arg1 / arg2
return result
except ZeroDivisionError:
return "Cannot divide by zero"