Python program to add two objects if both objects are of type integer


Topic: Python program to add two objects if both objects are of type integer

Solution

def add_numbers(a, b):
    if not (isinstance(a, int) and isinstance(b, int)):
        raise TypeError("Inputs must be integers")
    return a + b
print(add_numbers(10, 20))



List all Python Programs