Answer to Question #256512 in Python for rasi

Question #256512

  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)


1
Expert's answer
2021-11-04T11:44:11-0400
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)}")

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