- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to sum values of a Python dictionary?
It is pretty easy to get the sum of values of a python dictionary. You can first get the values in a list using the dict.values(). Then you can call the sum method to get the sum of these values.
example
d = { 'foo': 10, 'bar': 20, 'baz': 30 } print(sum(d.values()))
Output
This will give the output −
60
- Related Articles
- How to replace values of a Python dictionary?
- How to update a Python dictionary values?
- Map function and Dictionary in Python to sum ASCII values
- How to replace values in a Python dictionary?
- How to sort a dictionary in Python by values?
- How to print all the values of a dictionary in Python?
- How to get a list of all the values from a Python dictionary?
- How to convert Python dictionary keys/values to lowercase?
- How to find the average of non-zero values in a Python dictionary?
- How to select Python Tuple/Dictionary Values for a given Index?
- Accessing Values of Dictionary in Python
- How to create Python dictionary from list of keys and values?
- How to insert new keys/values into Python dictionary?
- How to concatenate a Python dictionary to display all the values together?
- How to define a Python dictionary within dictionary?

Advertisements