[EMAIL PROTECTED] a écrit :
(snip - already answered)
>
> def fact(n):
> total = 0
> n = int(n)
> while n > 0:
> total *= n
> n -=1
> return total
You may be interested in a very different way to get the same result:
from operator import mul
d
> My guess is that you want to initialize total to 1, not 0.
>
D'oh! Yes, you are right, thank you.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 17, 3:30 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> def fact(n):
> total = 0
> n = int(n)
> while n > 0:
> total *= n
> n -=1
> return total
>
My guess is that you want to initialize total to 1, not 0.
-- Paul
--
ht
Hi there,
I'm new to Python and I've been writing a rudimentary exercise in
Deitel's Python: How to Program, and I found that this code exhibits a
weird behavior. When I run the script, the for...range(1,11) structure
always starts with zero--and I've tried plugging other values as well!
>From the