dictionaries with nested lists

Alex Martelli aleax at aleax.it
Sat Nov 1 17:19:39 EST 2003


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'
> ?

No, but you can write dictionary[key][2] for that purpose:

-- that [list] notation is unneeded and unsupported,
-- indices start from 0 so the 3rd one is indexed as [2]


Alex





More information about the Python-list mailing list