Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- import functools
- import operator
- #dictionary of data
- candidates = [
- {'Joshua': 192,
- 'Aldrin': 48,
- 'Dianna': 206,
- 'Donna': 37,
- 'David': 195
- },
- {'Joshua': 200,
- 'Aldrin': 200,
- 'Dianna': 150,
- 'Donna': 67,
- 'David': 123
- }]
- def count_votes(candidate_dictionary):
- # sum the values with same keys
- result= dict(functools.reduce(operator.add,
- map(collections.Counter, candidate_dictionary)))
- return result
- print(count_votes(candidates))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement