9
Question Question 9
How is del D and del D[<key>] different from one another if D is a dictionary ?
del D is used to delete the whole dictionary where as del D[<key>] is used to delete only the key:value pair with the given key.
For example:
d = {1: 'a' , 2 : 'b'}
del d[2]
print(d)
del d
print(d)Output
{1:'a'}
NameError: name 'd' is not defined.