Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 5, 2020 06:24
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 IndhumathyChelliah/d2abfcc98a2d198968fdd7f8ac89c724 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/d2abfcc98a2d198968fdd7f8ac89c724 to your computer and use it in GitHub Desktop.
import itertools
l1=itertools.chain(["red","blue"],[1,2,3],"hello")
#Returns an iterator object
print (l1)#Output:<itertools.chain object at 0x029FE4D8>
#converting iterator object to list object
print(list(l1))#Output:['red', 'blue', 1, 2, 3, 'h', 'e', 'l', 'l', 'o']
l2=itertools.chain("ABC","DEF","GHI")
print (list(l2))#Output:['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment