Appending to a list, which is value of a dictionary

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Sat Oct 15 12:12:15 EDT 2016


Chris Angelico writes:

> On Sat, Oct 15, 2016 at 11:35 PM, Uday J wrote:
>>>>> bm=dict.fromkeys(l,['-1','-1'])
>
> When you call dict.fromkeys, it uses the same object as the key every
> time. If you don't want that, try a dict comprehension instead:

s/key/value/



More information about the Python-list mailing list