Kero
0
Q:

remove element from dictionary python

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
thisdict.pop("model")
6
del d[key]
4
dict.pop("key")
4
''' 
Deleting an entry from dictionary using del 
'''
# If key exist in dictionary then delete it using del.
if "at" in wordFreqDic:
    del wordFreqDic["at"]
    
print("Updated Dictionary :" , wordFreqDic)      
3
squares = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

# remove a particular item, returns its value
# Output: 16
print(squares.pop(4))
0

New to Communities?

Join the community