CBSE Class 11 Informatics Practices
Question 49 of 66
Dictionary — Question 21
Back to all questionsThe clear() function removes all the key:value pairs from the dictionary and makes it empty dictionary while del <dict> statement removes the complete dictionary as an object. After del statement with a dictionary name, that dictionary object no more exists, not even empty dictionary.
For example:
d = {1: 'a' , 2 : 'b'}
d.clear()
print(d)
del d
print(d)Output
{}
NameError: name 'd' is not defined.