Appending to a list, which is value of a dictionary
Chris Angelico
rosuav at gmail.com
Sat Oct 15 12:17:13 EDT 2016
On Sun, Oct 16, 2016 at 3:12 AM, Jussi Piitulainen
<jussi.piitulainen at helsinki.fi> wrote:
> 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/
What he said.
ChrisA
More information about the Python-list
mailing list