Let\'s say I have a dictionary in which the keys map to integers like:
d = {\'key1\': 1,\'key2\': 14,\'key3\': 47}
Is there a syntactically
I feel sum(d.values()) is the most efficient way to get the sum.
sum(d.values())
You can also try the reduce function to calculate the sum along with a lambda expression:
reduce(lambda x,y:x+y,d.values())