Question: Write a recursive function recNumberSum0 that takes an arbitrarily nested list as a parameter and returns a the sum of all numeric values found in
Write a recursive function recNumberSum0 that takes an arbitrarily nested list as a parameter and returns a the sum of all numeric values found in the list Note that the list may contain any Python type, not just strings. Recall that you can determine whether an item is a int by writing type(item) + int (float) and whether an item is a list by writing type (item) ## list. The function should not use any loops. The only list functions you are allowed to use are len0. indexing (lst[i] for an integer i), or slicing (lst[ for integers i and j). You should use string concatenation in writing your solution. If the list does not contain any number or is empty the function should return 0. The following shows several sample runs of the completed function: 1. >>> recNumber Sum ([1,2, 3]) >> recNumberSum ( [1, [[ I (51111,3]) >>> recNumber Sum ([1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
