> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/python/reduce-and-opeator.md).

# reduce and opeator

Reduce is operation that reducing an array into a single value.

For example multiplying all element in the array

```
a=[1,2,3,4,5,6]

from functools import reduce
from operator import mul
a=[1,2,3]

reduce(mul, a) 
# 6

# or with lambda

reduce(lambda x, y: x*y, a)
# 6
```
