Skip to content

Commit fb51377

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#408 from tyadav4268/patch-4
Create Use_of_filter_function.py
2 parents 32fc01a + af11144 commit fb51377

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Use_of_filter_function.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Program to extract a list of numbers that are multiples of 5 from a list of integers using filter function in python.
2+
# The filter function takes two arguments,
3+
# a function object and an iterable like list, tuple,etc.
4+
# The function object passed should return either true or false.
5+
6+
input_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
7+
8+
list_answer = list(filter(lambda x:x%5 == 0, input_list))
9+
10+
print(list_answer)
11+
12+
# Output: [5, 10, 15]

0 commit comments

Comments
 (0)