Question: Write a recursive function recListSum() that takes an arbitrarily nested list as a parameter and returns the sum of the numbers in the list. You

Write a recursive function recListSum() that takes an arbitrarily nested list as a parameter and returns the sum of the numbers in the list. You are not allowed to use any list methods in your function other than indexing (lst[i] for some integer i), slicing (lst[i:j] for some integers i and j), or len(). You may assume that the initial value given to the function is a list, and your function does not have to behave in any reasonable way when given something other than a list as a parameter. The list may contain values of any type and you must only take the sum of the ones that are integers or floating point values. The type() function is helpful in determining what values can be found in the list. Numbers found within other collections (tuples, dictionaries, etc.) should not be included in the sum. The following shows the behavior of the function on some sample parameters. Please remember that the examples are just that. Your function must work correctly on all valid parameters, and you may not make any assumptions about the number of nested sublists or the depth of the nesting in the list provided as a parameter to the function:

Write a recursive function recListSum() that takes an arbitrarily nested list as

Python 3.41 Shell File Edit Shel ebug Options Windows Help >> recListSum( >> val = recListSuml[1, 2, 3,'hello')) >> val reclistSu[1.2, test , [[3.14], bye, 12], (1, 2)]) 16.34 recistSum(LELEE[3.14, 10, 1, 6, 5, 9, 3]) 37.14 n: 37 Col: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!