Last active
November 12, 2017 15:44
-
-
Save pykong/e86355166c23a9663047ff8dca2334db to your computer and use it in GitHub Desktop.
Note that if the second argument, i.e. None is not given, KeyError is raised if the key is not in the dictionary. Providing the second argument prevents the conditional exception. This is unlike the mydict.get() method, which defaults to None. https://stackoverflow.com/questions/15411107/delete-a-dictionary-item-if-the-key-exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mydict.pop("key", None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment