Write a Python program to add two objects if both objects are an integer type
I have used python 3.7 compiler for debugging purpose.
def add_numbers(x, y): if not (isinstance(x, int) and isinstance(y, int)): raise TypeError("Inputs must be integers") return x + y print(add_numbers(30, 20))
Result:
50
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used python 3.7 compiler for debugging purpose.
Result:
50
need an explanation for this answer? contact us directly to get an explanation for this answer