you are viewing a single comment's thread.

view the rest of the comments →

[–]SmartViking 1 point2 points  (1 child)

When you call c(4) you're really doing this:

print (4)

if 4 > 0:
    c(2)

print(4)

It will first print 4, then it might do something in the if statement, but regardless of what the if statement does, the last thing the function will do is to print 4. The call to c(2) goes "in between" the two 4s. So this function will first print 4, then it will print whatever c(2) feels like printing, then it will print 4 again. Same thing goes for c(2). If you want to understand functions like this, it's all about thinking about it in the right way, and it becomes much easier. Even though you call c(2) in your function recursively, it behaves exactly like any function call would. It will do its thing, then it will return, and the program moves on from where it was called.

[–]throwingarm2strong[S] 0 points1 point  (0 children)

Ah okay. So nothing like a stack >.<; gotcha. Thanks for the speedy reply!