I have a certain string k that may or many not a key of a dict reversedmapping, and another dict spendDict where it may also be a key.
Why does the following check succeed (i.e. run to completion), for a value of k that is not a key of reversedmapping:
if (k not in reversedmapping) or (reversedmapping[k] not in spendDict)
whereas I get a KeyError (for k) when I change it to logical AND:
if (k not in reversedmapping) and (reversedmapping[k] not in spendDict):
And how do I rewrite the AND variant to avoid the KeyError?
 
     
     
    