Build a filter func tat takes list ,function as input and returns list of only those items wch pass specified condition in func | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Build a filter func tat takes list ,function as input and returns list of only those items wch pass specified condition in func

l=[1,2,3] set isEven(number) if number % 2==0: return True return False filter(l,isEven)-> Returns [2]

5th Mar 2017, 5:23 AM
charumathi.n
charumathi.n - avatar
1 Answer
+ 3
Why "build a filter func": in Python a such built-in function is already provided ( just the parameters are inversed )... l=[1,2,3] def isEven(number): return True if number&1==0 else False print(filter(isEven,l))
5th Mar 2017, 4:16 PM
visph
visph - avatar