Chrome Extension

Delete a key value pair from a dictionary in Python

To delete a key from a dictionary in python - del keyword can be used with the key name that you want to delete from the python dictionary.
my_car = {
  "name": "Nexon",
  "brand": "TATA",
  "color": "Green"

del my_car['color']

Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

In the code snippet, we are deleting a a key - color from dictionary - my_car

Search Index Data (The code snippet can also be found with below search text)

delete a key from dict python
Was this helpful?