Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import functools
- def f(dict1, dict2):
- interKeys = set(dict1.keys()) & set(dict2.keys())
- ans = {}
- def reducer(acc, elem):
- ans[elem] = dict1[elem] + dict2[elem]
- functools.reduce(reducer, interKeys, None)
- return ans
- print(f({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}, {'a': 1, 'd': 2, 'f': 3, 'g': 4, 'e': 5}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement