Understanding control flow of recursive function that uses splicing <p>I seem to be unable to understand why it is, that once the terminating base condition is met in a recursive function, the function continues to call itself and go back up the call stack. </p> <p>Here's an example recursive function written in Python 2.7:</p> <pre><code>text = "hello" def reverse_string(text): if len(text) &lt;= 1: return text return reverse_string(text[1:]) + text[0] </code></pre> <p>Using the <a href="http://www.pythontutor.com/visualize.html#mode=edit" rel="nofollow">Python visualizer</a>, I understand how as the function calls itself with <code>reverse_string(text[1:])</code> and each frame is created as follows: </p> <pre><code>Frames Global frame text "hello" reverse_string reverse_string text "hello" reverse_string text "ello" reverse_string text "llo" reverse_string text "lo" reverse_string text "o" Return value "o" </code></pre> <p>My question is this: why when the base condition is met (when <code>text = "o"</code>) does that trigger text[0] to start operating? I was thinking that all the code on that return statement/line would be working together at the same time, not understanding why <code>reverse_string(text[1:])</code> happens first, then <code>text[0]</code> — and again, why is <code>text[0]</code> activated when the base conditional is met?</p>