write a function to add any number of numbers for Eg. add(1,2) add(1,2,3) add(1,2,3,4,5)
Source code
def add(*args):
sum1=0
for arg in args:
sum1+=arg
return sum1
print("add(1,2) = ",add(1,2))
print("add(1,2,3) = ",add(1,2,3) )
print("add(1,2,3,4,5) = ",add(1,2,3,4,5))
Output
Comments
Leave a comment