Created
July 21, 2018 20:26
-
-
Save vinaykudari/2a673d81c41614236648c33fd4ebcc6a to your computer and use it in GitHub Desktop.
Filter function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_a = list(range(5)) | |
def is_greater(n): | |
if(n>2): | |
return True | |
else: | |
return False | |
f1 = filter(lambda x : x>2, list_a) #lambda function | |
f2 = filter(is_greater, list_a) #normal function | |
>> list(f1) | |
[3,4] | |
>> list(f2) | |
[3,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment