unknown 2 months ago
parent
commit
b5c97763e4
1 changed files with 9 additions and 4 deletions
  1. 9 4
      courses/python_func/filter.py

+ 9 - 4
courses/python_func/filter.py

@@ -5,11 +5,16 @@ def test_1():
     print(list(filter(lambda x: x[0] == x[-1], a)))
 
 
+def filter_numbers(lst: list):
+    return list(filter(lambda x: x%2 == 0 or abs(x) > 100, lst))
+
+
 def main():
-    pass
+    numbers = [-100, 2, -300, -400, 5, -60, -61, -101, 101]
+    print(filter_numbers(numbers))
 
 
 if __name__ == '__main__':
-    # main()
-    a = [1, 2, 3, 4, 5]
-    print(list(filter(None, a)))
+    main()
+    # a = [1, 2, 3, 4, 5]
+    # print(list(filter(None, a)))