python3 holding on to data after recursion

Solution 1:

This is documented behavior when using mutables as default arguments (see "Default parameter values are evaluated from left to right when the function definition is executed.").

As discussed in the documentation, "A way around this is to use None as the default, and explicitly test for it in the body of the function".

[While documented, I only learned about it here on SO a couple of days ago]