fork download
  1. def foo(d1, d2):
  2. result = {}
  3. for key in d1:
  4. if key in d2:
  5. result[key] = d1[key] + d2[key]
  6.  
  7. return result
  8.  
  9. x = dict(
  10. a=1, b=2, c=3, d=4,
  11. e=5, f=6, g=7, h=8,
  12. i=9, j=10, k=11, l=12,
  13. m=13, n=14, o=15,
  14. )
  15. y = dict(
  16. z=1, y=2, x=3, w=4,
  17. v=5, u=6, t=7, s=8,
  18. r=9, q=10, p=11, o=12,
  19. )
  20.  
  21. print(sum(foo(x, y).values()))
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
27