itertools-in-Python


Definition
Functional tools for creating and using iterators.

Methods
  • accumulate
  • chain
  • combinations
  • combinations_with_replacement
  • compress
  • count
  • cycle
  • dropwhile
  • filterfalse
  • groupby
  • islice
  • permutations
  • product
  • repeat
  • starmap
  • takewhile
  • zip_longest
Example
The return is:
 import itertools
x={1,2,3,4,5,6,7,8,9}
y=itertools.accumulate(x)
for value in y: print(value)

>>> 
1
3
6
10
15
21
28
36
45
>>> 

Comments