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 |