Answer to Question #255531 in Python for GANESH

Question #255531

write a function to add any number of numbers for Eg. add(1,2) add(1,2,3) add(1,2,3,4,5)


1
Expert's answer
2021-10-23T13:54:03-0400

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





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS