[Tutor] 15 puzzle
Remco Gerlich
scarblac@pino.selwerd.nl
Wed, 9 May 2001 12:02:09 +0200
On 0, Remco Gerlich <scarblac@pino.selwerd.nl> wrote:
> On 0, alan.gauld@bt.com wrote:
> > baselist = newList = []
>
> Oops. Assign by reference, remember?
>
> > for i in range(15): baseList.append(str(i))
>
> So this appends to both. (And later on as well).
Actually, it does still work, since the numbers are added to the end and
then ignored. But it's very confusing, and probably not intended :)
(I forgot to turn the numbers into strings, so should be
buttons = map(str, range(15))
random.shuffle(buttons)
)
--
Remco Gerlich