Re: reduce in loop

2010-04-04 Thread Terry Reedy
On 4/4/2010 7:46 PM, monkeys paw wrote: Why does the following fail with the Traceback? def add(x,y): return x+y for rrr in range(1,20): I presume that this was 'for r...' reduce(add, range(1, r)) and that this was indented. Traceback (most recent call last): File "", line 2, in TypeErr

Re: reduce in loop

2010-04-04 Thread Benjamin Kaplan
On Sun, Apr 4, 2010 at 7:46 PM, monkeys paw wrote: > 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 "", line 2, in > TypeError: reduce() of empty sequence with

reduce in loop

2010-04-04 Thread monkeys paw
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 "", line 2, in TypeError: reduce() of empty sequence with no initial value -- http://mail.python.org/mailman/listinfo/pytho