you call the function with argument i==3. It execute the if part (i.e. prints
It NEVER enters the
Try this site http://www.pythontutor.com/visualize.html
to visualise the execution and get better understanding
And by the way, don't use python2, use python3 instead. python2 is dead.
++++++
), because you call the function recursively when you call foo with i==5, it returns the what ever
. You just throw it away and then it continues on line 10 and prints "why is this printing?"
and then it exit the function (and return default None
, because there is no explicit return.It NEVER enters the
elif
block and never execute line 8 (where the only [explicit] return in the function is).Try this site http://www.pythontutor.com/visualize.html
to visualise the execution and get better understanding
And by the way, don't use python2, use python3 instead. python2 is dead.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs