Last active
December 11, 2015 04:59
-
-
Save graue/4549481 to your computer and use it in GitHub Desktop.
itertools.chain() in Python
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
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