Problem with lists

Chris Angelico rosuav at
Wed Sep 16 02:46:48 CEST 2015

On Wed, Sep 16, 2015 at 10:29 AM, Rafael David < at> wrote:
> Oooohhh ... I think I got it! I'm assigning a reference to peca and not the value itself! Thank you very much MRAB and C Smith for the enlightenment :)

Right! That's how Python's assignment always works. You may find, in
your case, that you can simply reassign peca={} every time through the
loop. No copying necessary - just make yourself a new dict for each

And you might be able to do the whole thing with a gigantic
list/list/dict comprehension, but that may or may not be an
improvement on your code :)


More information about the Python-list mailing list