map(), filter() and reduce() in Python — a practical guide to Python map filter reduce with clear examples you can reuse in real projects.
Python Tutorial Series (31/95). Prefer one article? Read the complete Python tutorial.
Short description
These tools process collections without explicit loops. `reduce` lives in `functools`.
Functional helpers
from functools import reduce
nums = [1, 2, 3, 4, 5]
print(list(map(lambda n: n * 2, nums)))
print(list(filter(lambda n: n % 2 == 0, nums)))
print(reduce(lambda a, b: a + b, nums))