Skip to content

Commit 1edef56

Browse files
authored
Create Filter_method.md
1 parent 97b3d10 commit 1edef56

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

snippets/python/Filter_method.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Filter Method
2+
#### The filter() method filters the given sequence with the help of a function that tests each element in the sequence to be true or not.
3+
4+
_tags_: filter
5+
6+
## Snippet
7+
```
8+
# following code will filter out the even number from a list of numbers
9+
10+
def checkEven(number):
11+
return number % 2 == 0
12+
13+
numberList = [9,2,1,8,6,4,5,3,7]
14+
evenList = filter(checkEven, numberList)
15+
16+
for item in evenList:
17+
print(item)
18+
```

0 commit comments

Comments
 (0)