Important Notice:

Course Content
The Calendar Module
Library Function/Predefined Functions
0/4
Sys Module
Library Function/Predefined Functions
0/2
OS Module
Library Function/Predefined Functions
0/2
Functions in Python (Chapter-10) M3-R5
About Lesson

Question:- Wap to filter the even number given range

val=[5,10,13,17,15,18,20,25,30]

def evencheck(x):

    if x%2==0:

        return True

    else:

        return False

even=filter(evencheck,val)

for x in even:

    print(x)

Output: 10 18 20 30

Using lambda Function

val=[5,10,13,17,15,18,20,25,30]

even=filter(lambda a:a%2==0,val)

for x in even:

    print(x)

Output

10 18 20 30

error: Content is protected !!