SyntaxFix
Write A Post
Hire A Developer
Questions
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())