Skip to content

Instantly share code, notes, and snippets.

@vinaykudari
Created July 21, 2018 20:26
Show Gist options
  • Save vinaykudari/2a673d81c41614236648c33fd4ebcc6a to your computer and use it in GitHub Desktop.
Save vinaykudari/2a673d81c41614236648c33fd4ebcc6a to your computer and use it in GitHub Desktop.
Filter function
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