36. write a function to add any number of numbers for Eg. add(1,2)
add(1,2,3)
add(1,2,3,4,5)
def add(*args):
sumResult=0
for n in args:
sumResult+=n
return sumResult
print(f"add(1,2) = {add(1,2)}")
print(f"add(1,2,3) = {add(1,2,3)}")
print(f"add(1,2,3,4,5) = {add(1,2,3,4,5)}")
Comments
Leave a comment