As an example I have a dictionary as follows:
mydict = {A:['asdasd',2,3], B:['asdasd',4,5], C:['rgerg',9,10]}
How can I get just one number that is essentially the sum of the weighted values of all the keys in the dict (this example: A, B, C
) weighted by the last number in the list (list[-1]
)?
So for instance, this would be the sum of:
(2/15)*3 + (4/15)*5 + (9/15)*10 = 7.73
Where 15 is the sum of 2,4,9.
At the moment I'm creating too many variables that just iterate through the dictionary. I'm sure there's a quick efficient Python way to do it.