Advanced functions and decorators · 6 / 15 Exercise Easy

Sum of any amount of numbers

Objective

Create a Python program with a function that adds as many numbers as it receives, using *args.

Instructions

  • Define def total(*numbers), which returns the sum of all the arguments received (0 if it receives none).
  • Read a line with integers separated by spaces and call the function unpacking the list with total(*list).
  • Show Sum: S.
Input
4 8 15 16 23 42
Output
Sum: 108

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise