Skip to content

Instantly share code, notes, and snippets.

@Kush1101
Created September 26, 2020 15:44
Show Gist options
  • Save Kush1101/7da33eac1653ee4309241c4d4af6aeaa to your computer and use it in GitHub Desktop.
Save Kush1101/7da33eac1653ee4309241c4d4af6aeaa to your computer and use it in GitHub Desktop.
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