Answered step by step
Verified Expert Solution
Question
1 Approved Answer
template we are supposed to use : (Python) https://drive.google.com/file/d/1rmamf9ppiNo_hy5RmnW5qgdfkJ-3XwW7/view?usp=sharing 2. Write a recursive function recListSum0 that takes an arbitrarily nested list as a parameter and
template we are supposed to use : (Python)
https://drive.google.com/file/d/1rmamf9ppiNo_hy5RmnW5qgdfkJ-3XwW7/view?usp=sharing
2. Write a recursive function recListSum0 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 (e.g. Ist[i] for some integer i), slicing (e.g. Ist[i:j] for some integers i and j), or lenO. The function may not use a loop. Solutions that use built-in functions rather than recursion to solve the problem will earn very little credit. 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 type0 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 these 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 >>> recListSum([1,2,3]) >>> recListsum (1) 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started