You should use the `get()` method from the `dict` class d = {} r = d.get( 'missing_key', None ) This will result in `r == None`. If the key isn't found in the dictionary, the get function returns the second argument.