Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Python

map(), filter() and reduce() in Python

Transform and filter iterables functionally with map, filter, and reduce.

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))

Leave a reply

Your email address will not be published. Required fields are marked *