Accepting a sequence of arbitrary length
-
Write a function that adds the given numbers together and printsthe sum.
-
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
OR
OR