Advertisement
STANAANDREY

Untitled

Jan 19th, 2023
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import functools
  2.  
  3.  
  4. def f(dict1, dict2):
  5. interKeys = set(dict1.keys()) & set(dict2.keys())
  6. ans = {}
  7. def reducer(acc, elem):
  8. ans[elem] = dict1[elem] + dict2[elem]
  9. functools.reduce(reducer, interKeys, None)
  10. return ans
  11.  
  12. 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