dictionaries with nested lists

ruari mactaggart ruari at charliefortune.com
Sun Nov 2 01:36:20 EST 2003


what if i mean
bands={'beatles':['john','paul','george','ringo'],['guitar','bass','guitar',
'drums']}

then i need to put bands['beatles'][1][3]='percussion'

i presume... ?

Joe Francia <usenet at soraia.com> wrote in message
news:JnWob.4104117$Bf5.558479 at news.easynews.com...
> ruari mactaggart wrote:
> > can i write
> >
> >>>>dictionary[key][list][3]
> >
> > to mean the 3rd item in the list that is the corresponding value for
'key' ?
>
> You don't need the [list] part.  Assuming you mean something like:
>
> bands = {'beatles': ['john','paul','george','ringo']}
>
> ...then bands['beatles'][3] == 'ringo'
>
> Peace,
> Joe
>






More information about the Python-list mailing list