SHOCK: WHY None?

Tim Golden mail at timgolden.me.uk
Fri Sep 21 10:06:40 EDT 2007


n00m wrote:
> def f(i,sm):
>     if i+1==len(a):
>         print sm+a[i]
>         return sm+a[i]
>     else:
>         f(i+1,sm+a[i])
> 
> a=[1,2,3,4,5]
> 
> print f(0,0)
> 
> 
> 15
> None

You're not actually returning anything from
the recursive call.

TJG



More information about the Python-list mailing list