Silently removing key from a python dict [duplicate]

Solution 1:

You can do this:

d.pop("", None)
d.pop(None, None)

Pops dictionary with a default value that you ignore.

Solution 2:

You could use the dict.pop method and ignore the result:

for key in [None, '']:
    d.pop(key, None)