1# Basic syntax:
2del dictionary['key']
3
4# Example usage:
5dictionary = {'a': 3, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
6del dictionary['c'] # Remove the 'c' key:value pair from dictionary
7dictionary
8--> {'a': 3, 'b': 2, 'd': 4, 'e': 5}
1'''
2Deleting an entry from dictionary using del
3'''
4# If key exist in dictionary then delete it using del.
5if "at" in wordFreqDic:
6 del wordFreqDic["at"]
7
8print("Updated Dictionary :" , wordFreqDic)
9
1dict = {'an':30, 'example':18}
2#1 Del
3del dict['an']
4
5#2 Pop (returns the value deleted, but can also be used alone)
6#You can optionally set a default return value in case key is not found
7dict.pop('example') #deletes example and returns 18
8dict.pop('test', 'Key not found') #returns 'Key not found'