LearnPy Hub
← Recursion & Lambda problems
Easy

Sum a List by Recursion

Write a recursive total(nums) that returns the sum of a list: the first item plus the total of the rest (an empty list is 0). Read integers and print it.

Input

Integers separated by spaces.

Output

One integer.

Sample 1

Input
1 2 3
Output
6

Sample 2

Input
10
Output
10
solution.py
Output appears here
Sum a List by Recursion · Python practice problem · LearnPy Hub