Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sum dictionary values by key

example_list = [
    {'points': 400, 'gold': 2480},
    {'points': 100, 'gold': 610},
    {'points': 100, 'gold': 620},
    {'points': 100, 'gold': 620}
]
sum(item['gold'] for item in example_list)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #sum #dictionary #values #key
ADD COMMENT
Topic
Name
3+1 =