How can i retrieve a key from a dictionary?

Gustavo Niemeyer niemeyer at conectiva.com
Mon Nov 5 09:48:20 EST 2001


Hi Husam!

> > Try this:
> >
> > dict.keys()[dict.values().index('one')]
> >
> > prabhu
> 
> it works, but wat does the -index-  means?

I'd advice you to work with two dictionaries, one of them being
reverse. Otherwise, there's no benefit in using dictionaries instead
of a plain lists.

Best regards!!

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20011105/e4aa1a8b/attachment.sig>


More information about the Python-list mailing list