Skip to content

Instantly share code, notes, and snippets.

@sk187
Created April 8, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk187/ecd5d521961cc7302c71 to your computer and use it in GitHub Desktop.
Save sk187/ecd5d521961cc7302c71 to your computer and use it in GitHub Desktop.
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