How to Remove Dictionary Elements and Dictionaries : pop « Dictionary « Python Tutorial






dict2 = {'name': 'earth', 'port': 80}
del dict2['name']       # remove entry with key 'name'
dict2.clear()           # remove all entries in dict1
del dict2               # delete entire dictionary








8.21.pop
8.21.1.pop method returns the value corresponding to a given key, and then remove the key-value pair from the dictionary
8.21.2.How to Remove Dictionary Elements and Dictionaries