NameError: name 'reduce' is not defined in Python

前端 未结 5 732
萌比男神i
萌比男神i 2020-11-29 17:49

I\'m using Python 3.2. Tried this:

xor = lambda x,y: (x+y)%2
l = reduce(xor, [1,2,3,4])

And got the following error:

l = re         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 18:22

    you need to install and import reduce from functools python package

提交回复
热议问题