BestPromptFinderBelow is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: In Python, create a function to find the maximum value within a nested dictionary. ### Input: sample_dict = { "key1": { "value1": 10, "value2": 20 }, "key2": { "value3": 40 }, } ### Output: def findMaxValue(dict): max_val = None for key, value in dict.items(): if isinstance(value, dict): max_val = max(findMaxValue(value), max_val) else: max_val = max(value, max_val) return max_val print(findMaxValue(sample_dict))
Find similar in the app →