Created
February 28, 2013 11:42
-
-
Save chirag-v/5056171 to your computer and use it in GitHub Desktop.
list comprehension method to get even numbers from a range.
This file contains hidden or 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
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