[Tutor] recursion surprise
Jim Mooney
cybervigilante at gmail.com
Sat Jun 8 23:46:56 CEST 2013
I was trying out simple recursion as below, with the printout I
expected, but it then also prints out "None" nine times. How does that
work?
Jim
#Using Python 3.3.2 on Win 7 - standard project, standard test file
def addone(num):
if num > 10:
return num
num = addone(num + 1)
print(addone(1))
Result:
11
None
None
None
None
None
None
None
None
None
--
Jim
"Would you use Internet Explorer if someone put a gun to your head?"
"How big is the gun?"
More information about the Tutor
mailing list