On Oct 23, 6:58 am, [EMAIL PROTECTED] wrote:
> On 22 oct, 23:39, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Nope, still doesn't work:
>
> > def fact(x):
> >         return reduce(operator.mul,xrange(1,x+1),1)
>
> > fact() should raise an exception if x is negative.
>
> So, where is the problem?

The fact that it returns 1 for negative x?

And didn't you see my followup message? About how the
example, as posted, doesn't even produce correct answers
for legal values of x?

> if not allowing negative numbers is so
> important for you,

Mathematical consistency is only important to _me_?

> add a if statement and raise a ValueError exception.

Not necessary when done correctly. Didn't you see my example?


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to