<font face="tahoma,sans-serif"><div>&gt;&gt; def f(n, history = []):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  history.append(n)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  return history</div>
<div><br></div><div>&gt;&gt;&gt; f(1)</div><div>[1]</div><div>&gt;&gt;&gt; f(2)</div><div>[1, 2]</div><div>&gt;&gt;&gt; f(3)</div><div>[1, 2, 3]</div><div>&gt;&gt;&gt; f(2)</div><div>[1, 2, 3, 2]</div><div>&gt;&gt;&gt; f(1)</div>
<div>[1, 2, 3, 2, 1]</div><div>&gt;&gt;&gt; f(1,[])</div><div>[1]</div><div><br></div><div>A student wrote me wondering why his function wouldn&#39;t &#39;clear&#39; after being called.  He meant to create an empty list and ended up with something like this.</div>
<div><br></div><div>What&#39;s a good way to explain what&#39;s going on?</div><div><br></div><div>- Michel</div><div><br></div><div><br></div></font><br>-- <br><div>==================================<br>&quot;What I cannot create, I do not understand.&quot;</div>
<div><br></div><div>- Richard Feynman</div>==================================<br>&quot;Computer science is the new mathematics.&quot;<div><br></div><div>- Dr. Christos Papadimitriou<br>==================================<br>
</div><br>