Skip to content

Instantly share code, notes, and snippets.

@graue
Last active December 11, 2015 04:59
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 graue/4549481 to your computer and use it in GitHub Desktop.
Save graue/4549481 to your computer and use it in GitHub Desktop.
itertools.chain() in Python
import itertools
fruits = ['apple', 'orange', 'grape']
veggies = ['cucumber', 'onion', 'potato']
juices = [thing + ' juice' for thing in itertools.chain(fruits, veggies)]
# >>> juices
# ['apple juice', 'orange juice', 'grape juice', 'cucumber juice', 'onion juice', 'potato juice']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment