reduce in loop

monkeys paw monkey at
Sun Apr 4 19:46:24 EDT 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