Iteration for Factorials
tokland at gmail.com
tokland at gmail.com
Tue Oct 23 07:58:56 EDT 2007
More information about the Python-list mailing list
Tue Oct 23 07:58:56 EDT 2007
- Previous message (by thread): Iteration for Factorials
- Next message (by thread): Iteration for Factorials
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 22 oct, 23:39, "mensana... at aol.com" <mensana... at aol.com> 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? if not allowing negative numbers is so important for you, add a if statement and raise a ValueError exception.
- Previous message (by thread): Iteration for Factorials
- Next message (by thread): Iteration for Factorials
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list