Python Lamba Syntax
# Python like Javascript is a functional langauge. It allows you to pass methods. | |
# To filter my_list for even numbers you can: | |
my_list = range(1,11) # Creates a list with the number 1 - 10 | |
# Filter Syntax is filter(params to filter by, list to filter) | |
print filter( lambda x: x%2==0, my_list) | |
# Returns | |
[2, 4, 6, 8, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment