What is wrong with the following?:
lss = reduce(list.extend, [[1],[2]], [])
causes:
Traceback (most recent call last):
File "<pyshell#230>", line 1, in <module>
lss = reduce(list.extend, [[1],[2]], [])
TypeError: descriptor 'extend' requires a 'list' object but received a 'NoneType'
I’m not sure where the NoneType is coming from.
Try this instead:
The problem is that
extend()returnsNone(that’s where theNoneTypeis coming from), and that won’t work with what you want to do – the function passed toreduce()must return a value: the accumulated result so far.