Function for Adding Integers or Floats with Type Check

  • Share this:

Code introduction


Define a function that attempts to add two arguments. If the arguments are not of type int or float, it returns an error message.


Technology Stack : Exception Handling

Code Type : Function

Code Difficulty :


                
                    
def aaaa(arg1, arg2):
    try:
        return arg1 + arg2
    except TypeError:
        return "Arguments must be of type int or float"