Created
September 17, 2013 23:49
-
-
Save kidchenko/6602387 to your computer and use it in GitHub Desktop.
List Comprehension Sintaxe.
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
new_list = [x for x in range(1,6)] | |
# => [1, 2, 3, 4, 5] | |
doubles = [x*2 for x in range(1,6)] | |
# => [2, 4, 6, 8, 10] | |
doubles_by_3 = [x*2 for x in range(1,6) if (x*2)%3 == 0] | |
# => [6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment