dimanche 2 juillet 2017

Python recursive function call with if statement

I have a question regarding function-calls using if-statements and recursion. I am a bit confused because python seems to jump into the if statements block even if my function returns "False"

Here is an example:

1    def function_1:
2       if function_2:
3           #do something
4           if x<y:
5               function_1(#different parameters)
6           if x>y:
7               function_1(#different parameters)

My function_2 returns "False" but python continues the code on line 5 for example. Can anyone explain this behavior? Thanks in advance for any answers.

Aucun commentaire:

Enregistrer un commentaire