Skip to main content
2 of 5
added 56 characters in body
Shameem
  • 2.8k
  • 20
  • 21
>>> if myDict.has_key(key): myDict.pop(key)


Another way

>>> {k:v for k, v in myDict.items() if k!='key'}

You can delete by conditions. No error if key doesn't exist

Shameem
  • 2.8k
  • 20
  • 21