reduce in loop

monkeys paw monkey at joemoney.net
Mon Apr 5 01:46:24 CEST 2010


Why does the following fail with the Traceback?

def add(x,y): return x+y
for rrr in range(1,20):
	reduce(add, range(1, r))

Traceback (most recent call last):
   File "<interactive input>", line 2, in <module>
TypeError: reduce() of empty sequence with no initial value



More information about the Python-list mailing list