Contents
- Addition
- The
func
parameter
The accumulate
functionitertools.accumulate
gives a running total.
Addition
For example, let’s try accumulating the numbers (1, 2, 3, 4, …):
>>> it = accumulate(count(1))
>>> list(islice(it, 8))
1, 3, 6, 10, 15, 21, 28, 36] [