[Tutor] recursion surprise
Jim Mooney
cybervigilante at gmail.com
Sun Jun 9 00:31:40 CEST 2013
On 8 June 2013 15:02, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> return None #Python puts the default return here as you don't specify
> it.
I wasn't quite sure where to put that 'return None' since it wasn't
aligned, so I tried a few different ways, did the below and it worked.
Is that what you meant or am I still confused ;')
#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)
if num != None:
print(num)
addone(1)
result: 11
More information about the Tutor
mailing list