Division Function with Zero Division Error Handling

  • Share this:

Code introduction


Define a function that performs division, and returns an error message if the divisor is zero.


Technology Stack : Built-in library

Code Type : Function

Code Difficulty : Intermediate


                
                    
def zebra(arg1, arg2):
    try:
        return arg1 / arg2
    except ZeroDivisionError:
        return "Error: Division by zero"