Adding through recursion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • martin.clausen@gmail.com

    #1

    Adding through recursion

    There is problaly a really simple answer to this, but why does this
    function print the correct result but return "None":

    def add(x, y):
    if x == 0:
    print y
    return y
    else:
    x -= 1
    y += 1
    add(x, y)

    print add(2, 4)

    result:
    6
    None

    Martin

Working...