If Dict Contains a particular key

Michael Bentley michael at jedimindworks.com
Tue Apr 24 13:37:19 EDT 2007


On Apr 24, 2007, at 12:28 PM, Robert Rawlins - Think Blue wrote:

> Hello Guys,
>
>
>
> I’m Looking to build a quick if/else statement that checks a  
> dictionary for a key like follows.
>
>
>
> If myDict contains ThisKey:
>
>                 Do this...
>
> Else
>
>                 Do that...
>
>
>
> Thats the best way of doing this?
if ThisKey in myDict:
   pass # do this
else:
   pass # do that


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070424/d4f42df9/attachment.html>


More information about the Python-list mailing list