If I have this type of dictionary:
a_dictionary = {"dog": [["white", 3, 5], ["black", 6,7], ["Brown", 23,1]],
"cat": [["gray", 5, 6], ["brown", 4,9]],
"bird": [["blue", 3,5], ["green", 1,2], ["yellow", 4,9]],
"mouse": [["gray", 3,4]]
}
And I would like to sum from first line 3 with 6 and 23 and on next line 5 with 4 on so on so I will have when printing:
dog [32, 13]
cat [9, 15]
bird [8, 16]
mouse [3,4]
I tried a for loop of range of a_dictionary to sum up by index, but then I can't access the values by keys like: a_dictionary[key]
But if I loop through a_dictionary like for key, value in a dictionary.items():
, I can't access it by index to sum up the needed values.
I would love to see how this could be approached. Thanks.