Problem with lists

Rafael David rdavid.br at gmail.com
Thu Sep 17 03:37:56 CEST 2015


Em terça-feira, 15 de setembro de 2015 21:47:10 UTC-3, Chris Angelico  escreveu:
> On Wed, Sep 16, 2015 at 10:29 AM, Rafael David <rdavid.br at gmail.com> 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
> iteration.
> 
> 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 :)
> 
> ChrisA

Yes, got it. Thanks Chris!

Guys, this group rocks :)


More information about the Python-list mailing list