Last active
December 20, 2018 11:02
-
-
Save bergpb/76a56d40e6dd16f1fe25a15ac899cbc0 to your computer and use it in GitHub Desktop.
Python list comprehensions.
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
| # example to use list comprehensions with python, the pythonic mode. | |
| def double_of_odds(list): | |
| return [x*2 for x in list if x%2] | |
| list = [1,2,3,4,5,6,7,8,9,10] | |
| double_of_odds(list) | |
| # out: [2, 6, 10, 14, 18] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment