Question: PYTHON: 1. 2. Write a recursive function depthCount0 that takes an arbitrarily nested list as a parameter and returns the maximum depth to which the
PYTHON:
1.

2.

Write a recursive function depthCount0 that takes an arbitrarily nested list as a parameter and returns the maximum depth to which the list has nested sublists. For example, a list with no sublists would have depth 0. A list with a sublist that contains no sublists itself would have depth 1. Every time a sublist of the list has a sublist itself, the depth increases by 1. There are several examples provided below for your reference. You are not allowed to use any list methods in your function other than indexing (e.g. lst i] for some integer slicing lstLij] for some integers i and j), or len0. Remember that you can test whether an item is a list by writing: if type(item) list. In writing the function you should not use any loops. 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 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. Python 3.4.1 She File Edit Shell Debug Options Windows Help depthCount (CJ) depthCount (01, 2, 31) depthCount (CC1] [2 3]] depthCount (CCC 1] 1, 12, 3]]) depthCount ([[1] [2] 31]) depthCount (ECC111 3]]) depthCount ([1 [2] 3] Ln: 39 Col: 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
