Here is one way to write the function
depth = lambda L: isinstance(L, list) and max(map(depth, L))+1
I think the idea you are missing is to use max()
More Related Contents:
- Find the sum of two lists of lists element-wise [closed]
- List comprehension on a nested list?
- Extract first item of each sublist
- Finding max value in the second column of a nested list?
- Comprehension on a nested iterables?
- Flattening a list recursively [duplicate]
- How can I use list comprehensions to process a nested list?
- Turning a list into nested lists in python
- How to zip two lists of lists
- I don’t know how to display step 3 for this assignment
- How to make a dict from n’th indices of tuples in list
- How do I concatenate items in a list to a single string?
- Is there a zip-like function that pads to longest length?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- How to use a dot “.” to access members of dictionary?
- Slicing a list in Python without generating a copy
- Python list doesn’t reflect variable change
- Take the content of a list and append it to another list
- How to find the maximum value in a list of tuples? [duplicate]
- In Python, why is list[] automatically global?
- Why do I get “List index out of range” when trying to add consecutive numbers in a list using “for i in list”? [duplicate]
- List to array conversion to use ravel() function
- convert a string which is a list into a proper list python
- Get difference between two lists with Unique Entries
- How to get the previous element when using a for loop? [duplicate]
- Combining lists into one [duplicate]
- split string in python to get one value?
- Turn a single number into single digits Python [duplicate]
- Optimal method to find the max of sublist items within list
- In what case would I use a tuple as a dictionary key? [closed]