Question: template You often have to work with nested data structure. For example, the dictionary on the RHS is a dictionary of list. Your task is

You often have to work with nested data structure. For example, the

template

dictionary on the RHS is a dictionary of list. Your task is 

You often have to work with nested data structure. For example, the dictionary on the RHS is a dictionary of list. Your task is to sum the numbers in each list. For example sum_numbers(my_dict) returns another dictionary that looks like below { } 5: 15, 2: 3, 3: 2, 4: 0, 1: None If the list is empty, the value should be None, if the list contains non-numerical values, ignore the items. Your dictionary should be sorted by the value in descending order. if dict[key1] and dict[key2] have the same values, sort the entries by key value, for example my_dict = { 1: [1], 2: [2, '2'], 3: ['2',2] } would return { } 2: 4, 3: 4, 1: 1 You often have to work with nested data structure. For example, the dictionary on the RHS is a dictionary of list. Your task is to sum the numbers in each list. For example sum_numbers(my_dict) returns another dictionary that looks like below { } 5: 15, 2: 3, 3: 2, 4: 0, 1: None If the list is empty, the value should be None, if the list contains non-numerical values, ignore the items. Your dictionary should be sorted by the value in descending order. if dict[key1] and dict[key2] have the same values, sort the entries by key value, for example my_dict = { 1: [1], 2: [2, '2'], 3: ['2', 2] } would return { } 2: 4, 3: 4, 1: 1 You often have to work with nested data structure. For example, the dictionary on the RHS is a dictionary of list. Your task is to sum the numbers in each list. For example sum_numbers(my_dict) returns another dictionary that looks like below { } 5: 15, 2: 3, 3: 2, 4: 0, 1: None If the list is empty, the value should be None, if the list contains non-numerical values, ignore the items. Your dictionary should be sorted by the value in descending order. if dict[key1] and dict[key2] have the same values, sort the entries by key value, for example my_dict = { 1: [1], 2: [2, '2'], 3: ['2',2] } would return { } 2: 4, 3: 4, 1: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Iiterating through the dictionary and each list within it summing the numerical values ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!