How to get a key from dictionary?

Bengt Richter bokr at oz.net
Tue Mar 26 18:15:27 EST 2002


On Wed, 27 Mar 2002 08:28:38 +1200, Matthew Sherborne <miracle at paradise.net.nz> wrote:

>This is a multi-part message in MIME format.
>
>------=_NextPart_000_002A_01C1D569.652C29C0
>Content-Type: text/plain;
>	charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>Sorry to be a show off, but I reckon that this way may be faster. Sorry =
>again. The other replies are very helpful.  :)
>
>def findKey(val):
>  for key, value in dict.items():
>    if value =3D=3D val: return key
>  return None
> =20
>GBU
>Matthew Sherborne
>
I have no problem with your showing off (since the risk is all yours ;-)
but I really dislike reading literal HTML. Please try to avoid posting it ;-/
(No, I won't switch to outlook ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list