To delete a key regardless of whether it is in the dictionary, use the two-argument form of
This will return
key exists in the dictionary, and
None otherwise. If the second parameter is not specified (ie.
key does not exist, a
KeyError is raised.
To delete a key that is guaranteed to exist, you can also use
This will raise a
KeyError if the key is not in the dictionary.