Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions snippets/python/Filter_method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Filter Method
#### 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.

_tags_: filter

## Snippet
```
# following code will filter out the even number from a list of numbers

def checkEven(number):
return number % 2 == 0

numberList = [9,2,1,8,6,4,5,3,7]
evenList = filter(checkEven, numberList)

for item in evenList:
print(item)
```