Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df45630

Browse files
Merge pull request #19 from aakashdinkar/master
Create Filter_method.md
2 parents a8cece1 + 1edef56 commit df45630

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)

AltStyle によって変換されたページ (->オリジナル) /