Skip to content

Instantly share code, notes, and snippets.

@Kush1101
Created Sep 26, 2020
Embed
What would you like to do?
from itertools import chain
for i in chain([0,1,2,3], range(4,11), 'ABC'):
print(i, end = ' ')
#OUTPUT
'''
0 1 2 3 4 5 6 7 8 9 10 A B C
'''
my_iterable = [[0,1,2],[3,4],[5,6,7,8,9,10],['ABC']]
for i in chain.from_iterable(my_iterable):
print(i, end = ' ')
#OUTPUT
'''
0 1 2 3 4 5 6 7 8 9 10 ABC
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment