Functools Reduce

Learn how to make your own reduce function for iterables using "functools reduce".

functools's reduce function

If the reducing functions discussed in the previous lessons don’t meet your needs, don’t worry. You can create your own using the reduce function.

This function lets you define your own behavior. For example, suppose we want to reduce a list by multiplying the elements. We can do the following:

Get hands-on with 1400+ tech skills courses.