Search code snippets, questions, articles...

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']


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?
Programming Feeds
Learn something new everyday on Devsheet