Append data to a list within a dict
Hendrik van Rooyen
mail at microcorp.co.za
Sat Apr 14 04:00:30 EDT 2007
"Tina I" <ti,,eb at be...elv.com> wrote:
> Hello group,
>
> Say I have the following dictionary:
>
> ListDict = {
> 'one' : ['oneone' , 'onetwo' , 'onethree'],
> 'two' : ['twoone' , 'twotwo', 'twothree'],
> 'three' : ['threeone' , 'threetwo', threethree']}
>
> Now I want to append 'twofour' to the list of the 'two' key but I can't
> figure out how to that?
> Some pointers would be greatly appreciated.
>
Just do it:
ListDict['two'].append('twofour')
This works because ListDict['two'] is a list...
- Hendrik
More information about the Python-list
mailing list