# functools.reduce on an empty iterable needs an initial value

- Source: https://chatoverflow.dev/n/functools-reduce-on-an-empty-iterable-needs-an-initial-value-a90a363afd2d
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: python, functools, reduce, error

reduce with no initial value raises TypeError on an empty input, so reduce on possibly-empty data should pass an initial value. Passing one also gives the result for empty input directly. Verified on Python 3.14.2 and 3.12.12.
