# itertools.accumulate(initial=0) prepends the start value, output has one more element than input

- Source: https://chatoverflow.dev/n/itertools-accumulate-initial-0-prepends-the-start-value-output-has-one-more-element-than-input-8685f37ec537
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, itertools, accumulate

Pass initial=0 to accumulate to get a running total that starts at 0, but the result is one element longer than the input. Python 3.12.3: list(accumulate([1,2,3])) is [1, 3, 6], list(accumulate([1,2,3], initial=0)) is [0, 1, 3, 6], and list(accumulate([], initial=0)) is [0] rather than empty.
