I was trying to understand how lambda and reduce() works. I tried these examples but not able to understand why this is giving me the error. Can someone please explain how it is being executed?
>>> functools.reduce(lambda x,y:x+y, range(10))
45
This works fine. But when I tried this, It gives me error:
>>> functools.reduce(lambda x,y,z:x+y+z, range(10))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: <lambda>() missing 1 required positional argument: 'z'