Accepting Sequence Arbitrary Length Write Function Adds Given Numbers Together Prints Sum Q37051403

Accepting a sequence of arbitrary length

  1. Write a function that adds the given numbers together and printsthe sum.

  2. Then add any other numbers that were sent to the arbitrarynumber of arguments and print the

    results
    HINT: * is needed for arbitrary number of arguments

Example: if your numbers are (1, 2, 3) the output should be: Thesum of your numbers is 6

use python


Solution


def sum(*args): total = 0 for num in args: total += num return totalprint(sum(1, 2, 3))

6 Process finished with exit code 0

color{blue}Please;let;me;know;if;you;have;any;doubts Please;upvote;this;answer.;;Thanks!!

6

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.