How can i retrieve a key from a dictionary?
Husam
h.jehadalwan at student.kun.nl
Sun Nov 4 06:59:56 EST 2001
Prabhu Ramachandran wrote:
> >>>>> "HJ" == Husam <h.jehadalwan at student.kun.nl> writes:
>
> HJ> how can one retrieve or select a key from a dictionary?
> HJ> dict={} dict[1]='one' dict[2]='two'
>
> HJ> dict.keys() will gets all the keys. but, i need to select
> HJ> explicitly one key for printing along its value.
>
> Try this:
>
> dict.keys()[dict.values().index('one')]
>
> prabhu
it works, but wat does the -index- means?
More information about the Python-list
mailing list