Chrome Extension

Remove a key from a dictionary Python

my_score = {
    "math": 90,
    "physics": 80,
    "chemistry": 85,
    "english": 91
#TO REMOVE 'physics' kEY from my_score
del my_score['physics']
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
To delete a key from a dictionary in python you can use the del keyword before dict['key_name']

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

delete a key from dict python
Was this helpful?
Join Devsheet Ask a Question