Last active
November 20, 2017 11:09
-
-
Save erikaris/1a445582057b1cc1f513bdc1644055cd to your computer and use it in GitHub Desktop.
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
# modified from: http://jmduke.com/posts/a-gentle-introduction-to-itertools/ | |
import itertools | |
letters = ['a', 'b', 'c', 'd', 'e', 'f'] | |
booleans = [1, 0, 1, 0, 0, 1] | |
numbers = [23, 20, 44, 32, 7, 12] | |
decimals = [0.1, 0.7, 0.4, 0.4, 0.5] | |
print("before cast to a list: " + str(itertools.chain(letters, booleans, decimals))) | |
print("after cast to a list : " + str(list(itertools.chain(letters, booleans, decimals)))) | |
# =============================== OUTPUT ================================================= | |
# before cast to a list: <itertools.chain object at 0x7f30b9ee4e48> | |
# after cast to a list : ['a', 'b', 'c', 'd', 'e', 'f', 1, 0, 1, 0, 0, 1, 0.1, 0.7, 0.4, 0.4, 0.5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment