Skip to content

Instantly share code, notes, and snippets.

@bergpb
Last active December 20, 2018 11:02
Show Gist options
  • Select an option

  • Save bergpb/76a56d40e6dd16f1fe25a15ac899cbc0 to your computer and use it in GitHub Desktop.

Select an option

Save bergpb/76a56d40e6dd16f1fe25a15ac899cbc0 to your computer and use it in GitHub Desktop.
Python list comprehensions.
# 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