Newbie question about for...in range() structure

Paul McGuire ptmcg at austin.rr.com
Thu Apr 17 04:37:28 EDT 2008


On Apr 17, 3:30 am, "sp at k" <spockspla... at gmail.com> 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



More information about the Python-list mailing list