How to make a python dictionary key error return false
<p>I am dealing with JSON data sets with dynamic response structures (keys) and need to execute code if certain keys exist. Right now if the key doesn't exist it throws a key error which I have attempted to pass through a bool operand but it appears the key error trumps bool operands in Python. </p>

<pre><code>bool(dictionary['key'])

KeyError: 'key'
</code></pre>

<p>I feel like there is some way to do this that's easier than I'm attempting but just haven't been able to find anything through researching. Any help would be greatly appreciated. </p>