By using the del keyword, you can delete the entire dictionary or the dictionary's items. If you want to delete the dictionary's items, use the following syntax:
del dict[key]
Considering the following code snippet for example:
>>> port = {80: "HTTP", 23 : "Telnet", 443 : "HTTPS"}
>>> del port[23]
>>> port
{80: 'HTTP', 443: 'HTTPS'}
>>>
If you want to delete the entire dictionary, then use the following syntax:
The del dict
Consider the following example:
>>> port = {80: "HTTP", 23 : "Telnet", 443 : "HTTPS"}
>>> del port
>>> port
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
port
NameError: name 'port' is not defined
>>>
The preceding error shows that the port dictionary has been deleted.