NameError: name reduce is not defined in Python

NameError: name reduce is not defined in Python

It was moved to functools.

You can add

from functools import reduce

before you use the reduce.

NameError: name reduce is not defined in Python

Or if you use the six library

from six.moves import reduce

Leave a Reply

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