What Is the reduce() Function?
In this lesson, you’ll learn how to use the
reduce() function (or
functools.reduce() in Python 3), which is one of the functional programming primitives (or building blocks) available in Python. It takes a function, a sequence (or iterable), and an optional initial value.
You’ll walk through how you can use the
reduce() function with the data set that you’ve been using in this course to reduce a sequence to a sinlge output value by applying a function repeatedly in order to output a single value.
Comments & Discussion
Become a Member to join the conversation.