Describing itertools.chain(*iterables)
- The
chainfunction is used to cycle through each element of any number of iterables - Each iterable is based on the
*iterablesparameters chainreturns an iterator of cycled elements- The
*iterablesparameter accepts any number of iterables
Illustrating the accumulate Function
>>> from itertools import chain
>>> nums = [1, 2, 3]
>>> letters = 'abc'
>>> itr = chain(nums, letters)
>>> for i in itr: print(i)
1
2
3
'a'
'b'
'c'References
Previous
Next