[Tutor] Function returns 'None'
Dominik Danter
dotti at socialnerds.org
Sun Jul 11 15:59:59 CEST 2010
Hello
As en exercise I wrote the following function:
def recursfac(x,carryover=1):
print 'x:',x,'carryover:', carryover
if x > 1:
carryover *= x
recursfac(x-1, carryover)
else:
return carryover
print recursfac(3)
Very much to my surprise I get the following output:
x: 3 carryover: 1
x: 2 carryover: 3
x: 1 carryover: 6
None
Where did I go wrong?
Kind regards
Dominik Danter
More information about the Tutor
mailing list