Advertisement
STANAANDREY

lsd6 dict 3

Nov 9th, 2022 (edited)
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import functools
  2.  
  3.  
  4. def my_filter(f, d):
  5.     ans = dict()
  6.  
  7.     def red_funct(prev, curr):
  8.         if f(d[curr]):
  9.             ans[curr] = d[curr]
  10.  
  11.     functools.reduce(red_funct, d, None)
  12.     return ans
  13.  
  14.  
  15. d = {'a': 2, 'c': 33, 'b': 3, 'asd': 11}
  16. print(my_filter(lambda e: e >= 5, d))
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement