filter.py 360 B

123456789101112131415161718
  1. # filter Принимает True или False
  2. def f(x):
  3. return x > 10
  4. def test_filter():
  5. a = [1, 0, 23, 0, 34, 2, 7, 3, 45]
  6. l_1 = list(filter(f, a))
  7. l_2 = list(filter(bool, a))
  8. print(l_1)
  9. print(l_2)
  10. def f_1():
  11. numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  12. print(list(filter(lambda x: not x%2, numbers)))
  13. f_1()