In a message of Tue, 07 Jun 2011 21:51:31 PDT, michel paul writes:
>>> def f(n, history = []):
> history.append(n)
> return history
>
>What's a good way to explain what's going on?
>
>- Michel
Assuming that you have already taught about the difference between
mutable and immutable objects, a
On Tue, Jun 7, 2011 at 9:51 PM, michel paul wrote:
> >> def f(n, history = []):
> history.append(n)
> return history
>
> >>> f(1)
> [1]
> >>> f(2)
> [1, 2]
> >>> f(3)
> [1, 2, 3]
> >>> f(2)
> [1, 2, 3, 2]
> >>> f(1)
> [1, 2, 3, 2, 1]
> >>> f(1,[])
> [1]
>
> A student wrote me wondering why hi