Skip to content

Instantly share code, notes, and snippets.

@chirag-v
Created February 28, 2013 11:42
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 chirag-v/5056171 to your computer and use it in GitHub Desktop.
Save chirag-v/5056171 to your computer and use it in GitHub Desktop.
list comprehension method to get even numbers from a range.
def even(x):
return x % 2 == 0
[num for num in range(10) if even(num)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment