SyntaxFix
Write A Post
Hire A Developer
Questions
You can use dict.pop:
dict.pop
mydict.pop("key", None)
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.
None
KeyError