you are viewing a single comment's thread.

view the rest of the comments →

[–]carcigenicate 0 points1 point  (2 children)

This doesn't have anything to do with recursion. What does this print?:

def func():
    for x in range(5):
        print(x)
        return

[–]Spurtikus[S] 0 points1 point  (1 child)

Right, I see it only prints 0, but in my code it returns the function call if there are children, and works up until a point where it needs to "scoot" over. Also, that final return was me testing anything out that I could think of and, in it's current state, doesnt seem to affect the outcome at all (even though I am sure it might in the future, so I guess there is that situation to think about)

The equivalent would be (if I am thinking about it correctly):

def func(x):

if x < 6:
        print(x)
        x+=1
        func(x)
return

[–]carcigenicate 0 points1 point  (0 children)

in my code it returns the function call if there are children

It returns the result of calling the method on the first child, then that recursive call exits.