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.
Or if you use the six library
from six.moves import reduce
In this case I believe that the following is equivalent:
l = sum([1,2,3,4]) % 2
The only problem with this is that it creates big numbers, but maybe that is better than repeated modulo operations?