Mega Code Archive

 
Categories / Python Tutorial / Dictionary
 

How to Remove Dictionary Elements and Dictionaries

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