LearnPy Hub
← Recursion & Lambda problems
Medium

Sum of a Nested List

Write a recursive deep_sum(x) that adds every number in a list that may contain lists inside lists. Read a Python list literal with ast.literal_eval and print the total.

Input

One list literal.

Output

One integer.

Sample 1

Input
[1, [2, 3], [[4]]]
Output
10

Sample 2

Input
[]
Output
0
solution.py
Output appears here
Sum of a Nested List · Python practice problem · LearnPy Hub