0 out of 464 challenges solved
Write a function `dict_depth(d)` that calculates the depth of a nested dictionary. The depth of a dictionary is defined as the maximum number of nested dictionaries within it, including the dictionary itself. #### Example Usage: ```python [main.nopy] print(dict_depth({'a': 1, 'b': {'c': {'d': {}}}})) # Output: 4 print(dict_depth({'a': 1, 'b': {'c': 'python'}})) # Output: 2 print(dict_depth({1: 'Sun', 2: {3: {4: 'Mon'}}})) # Output: 3 ``` #### Constraints: - The input will always be a dictionary. - The dictionary can contain other dictionaries, lists, or primitive data types as values.
def dict_depth(d): """ Calculate the depth of a nested dictionary. Args: d (dict): The dictionary to evaluate. Returns: int: The depth of the dictionary. """ # Placeholder for the solution pass