Question: Need help with Intro to Comp Sci 2 (Python) problem: Write a recursive function getTot () that returns the sum of a given list passed

Need help with Intro to Comp Sci 2 (Python) problem:

Need help with Intro to Comp Sci 2 (Python) problem: Write a

Write a recursive function getTot () that returns the sum of a given list passed in as a parameter that occurs in an arbitrarily nested list of numbers.. If the list is empty, the function returns 0. Otherwise the function returns the sum of all values in the list. Note that your function must be recursive. You are not allowed to use any list methods in your function other than indexing (e.g. 1 st [i] for some integer i, or 1 en(). You are encouraged to use the type () function. In writing the function you should not use any loops or global variables, and you cannot change the number of parameters of the function or define any helper functions. You may assume that the initial values given to the function are 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 function must return and not print the count of the number of occurrences of the string. 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 in the parameter list

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!