python recursive function not initializing default argument values
<p>So I have a helper function that is supposed to print out the internal nodes and leaves of a binary tree (unsorted). I won't provide the code since I'm in a class, but I can tell you that I have coded it up and it works for the first node I throw in there:</p>

<pre><code>def helper(root, internals=[], leaves=[]):
    #function code here...
&gt;&gt;&gt; helper(node)
    ([13, 14, 27], [10, 11, 12, 17, 19])
</code></pre>

<p>which is the correct output, as far as I know. However, when I call the same function again on <em>another</em> node, the output is overwritten into the previous one:</p>

<pre><code>&gt;&gt;&gt; helper(pen)
    ([13, 14, 27, 6, 8, 14], [10, 11, 12, 17, 19, 2, 4, 10, 12])
</code></pre>

<p>which is incorrect, since the tree <code>pen</code> does not have the elements 13,14,27 or 10,11,12,17,19. Can someone explain what's going on here? I have to test my function for different cases without restarting the shell every single time. How do I fix this?</p>
