NameError: name 'reduce' is not defined in Python NameError: name 'reduce' is not defined in Python python python

NameError: name 'reduce' is not defined in Python


You can add

from functools import reduce

before you use the reduce.


Or if you use the six library

from six.moves import reduce