Skip to content
C

Flexible Sum Function

Easypython

Write a function total(*numbers) that accepts any number of arguments and returns their sum, then use it on a line of space-separated numbers.

What the problem means: instead of writing a function that only adds exactly two numbers, use *args so it can add any amount of numbers you give it — 2, 5, or 20.

Approach: *numbers collects every argument passed into total() as a tuple; sum() adds them all up.

Input: One line: space-separated whole numbers.

Output: One line: the sum of all the numbers.

Input (stdin)

Output

Run your code to see output here...