Given a Python list whose elements are either integers or lists of integers (only we don't know how deep the nesting goes), how can we find the sum of each individual integer within the list?
It's fairly straightforward to find the sum of a list whose nesting only goes one level deep, e.g.
[1, [1, 2, 3]]
# sum is 7
But what if the nesting goes two, three, or more levels deep?
[1, [1, [2, 3]]]
# two levels deep
[1, [1, [2, [3]]]]
# three levels deep
The sum in each of the above cases is the same (i.e. 7). I think the best approach is using recursion where the base case is a list with a single integer element, but beyond that I'm stuck.