[Tutor] recursion surprise

Jim Mooney cybervigilante at gmail.com
Sun Jun 9 03:18:37 CEST 2013


On 8 June 2013 18:08, Steven D'Aprano <steve at pearwood.info> wrote:

> Is this enough information for you to fix it?

Yes, I was tripping over myself. Once I simplified it, it became clear:

def addone(n):
    if n > 5:
        return n
    return addone(n + 1)

result: 6
-- 
Jim


More information about the Tutor mailing list