Question: Need help with Intro to Comp Sci 2 (Python) problem: The functions written must not use global variables. In some cases certain built-in functions are
Need help with Intro to Comp Sci 2 (Python) problem:
The functions written must not use global variables. In some cases certain built-in functions are restricted in your solutions so carefully read each question. Solutions that don't follow these guidelines will not earn full credit, even if they produce the correct results in all cases.
Write a recursive function sublstCount() that takes an arbitrarily nested list as a parameter and returns the number of sublists in the list. You are not allowed to use any list methods in your function other than indexing (e.g. lst[i] for some integer i), slicing (e.g. lst[i:j] for some non-negative integers i and j), or len(). The function must be recursive and must return (NOT print) the number ofsublists. This function may not use any loops. Remember that you can test whether an item is a list by writing: if type(item) == list. 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. 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. The following shows the function results on several parameters:

Write a recursive function itemCount() that takes an arbitrarily nested list as a parameter and returnsthe number of items in the list. An item is a non-list value stored inside the list or inside of some sublistof the list (or a sublist of a sublist of the list, etc.) You are not allowed to use any list methods in your function other than indexing (e.g. lst[i] for some non-negative integer i) or slicing (e.g. lst[i:j] for some non-negative integers i and j). The function should not use a loop. The function must be recursive and must return (not print) the number of items. Remember that you can test whether an item is a list by writing: if type(item) == list. 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.

Python 3.4.1 She Eile Edit Shell Debug Options Windows Help sub lstcount (CJ) val sub lst Count (C1, 2, 3, 4]) val sublstCount ([1 C2, 131, 41, [5] sublst Count (CCC1], [2]] [3], [[4, C5] 1, 6] sub lst Count (C [1] [2] [3] [4] sublstCount (CCJ, CC]], Ln: 18 Col: 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
