[Tutor] recursion surprise
Jim Mooney
cybervigilante at gmail.com
Sun Jun 9 01:12:33 CEST 2013
On 8 June 2013 15:43, Dave Angel <davea at davea.name> wrote:
> On 06/08/2013 05:46 PM, Jim Mooney wrote:
> Post the same code that you ran, to get that output. Otherwise you're
> wasting our time.
Okay, here it is not working a different way, copied exactly, but it
looks like I do have a return statement, and that it should be
returning 11, not None. I must be missing something in my
understanding:
def addone(num):
if num > 10:
return num
num = addone(num + 1)
print(addone(1))
result:
>>>
None
>>>
More information about the Tutor
mailing list