Created
April 8, 2015 16:48
-
-
Save sk187/ecd5d521961cc7302c71 to your computer and use it in GitHub Desktop.
Python Lamba Syntax
This file contains 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
# 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