[Tutor] appending/updating values dict key value pairs

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Jun 22 19:04:24 CEST 2013


On 22/06/2013 17:56, Sivaram Neelakantan wrote:
>
> What's the best way to append to the list which is the value to a dict
> key?
>
> I did the following based on the docs and I'm not sure why it works
>
>>>> b = { 'a': [4, 5]}
>>>> list.append(b.get('a'),'c')
>>>> b
> {'a': [4, 5, 'c']}
>>>>
>
>
> as in, shouldn't it be
>
> b['a'] = list.append(b.get('a'),'c')
>
> which doesn't seem to work.
>
>   sivaram
>   --

b['a'].append('c')

-- 
"Steve is going for the pink ball - and for those of you who are 
watching in black and white, the pink is next to the green." Snooker 
commentator 'Whispering' Ted Lowe.

Mark Lawrence



More information about the Tutor mailing list