We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2643ce4 commit 7373f4fCopy full SHA for 7373f4f
lambda/example_lambda_filter.py
@@ -0,0 +1,28 @@
1
+## RETURN THE NUMBER IF IT IS EVEN
2
+
3
+# CHECK_EVEN FUNCTION DEFINE
4
+def check_even(num):
5
6
+# RETURN THE NUMBER IF THE CONDITION IS TRUE
7
+ return num%2==0
8
9
+# GIVING INPUTS TO THE NUMS
10
+nums = [1,2,3,4,5,6]
11
12
+# HERE WE PRINT WITH THE FILTER AND IN LIST FORMAT
13
+print(list(filter(check_even,nums)))
14
15
+# PRINT USING FOR LOOP
16
+for i in filter(check_even,nums):
17
+ print(i)
18
19
+## SIMPLE OUTPUT
20
+# HOW TO RUN
21
+# PYTHON: example_lambda_filter.py
22
+# [2, 4, 6]
23
24
+## OUTPUT AFTER USING THE FOR LOOP
25
26
+# 2
27
+# 4
28
+# 6
0 commit comments