What is clear() method in dictionary | How to use the clear() method of a dictionary.


This method of dictionary is used to remove all the elements and returns an empty dictionary. Also note that this method does not delete the dictionary, it only removes its item.



This method does not take any argument, passing an argument will throw an error.




You can copy code here.

dictionary = {1:’Student’,
‘Name’:’Waqar Khan’,



  1. A dictionary with variable name ‘dictionary’ is defined and some different key: value pairs are passed as data.
  2. clear() method of the dictionary is applied.
  3. Value of the variable dictionary is printed.


  1. An empty dictionary as output is shown.

Interview questions:

  • What is the difference between clear() method of dictionary, set or lists?

clear() empty or say deletes the item from dictionary, set or lists, so technically there is no difference between them.

Related Post:

Waqar Khan

Hello, everyone, I am Waqar Khan. I have done my B.tech in Computer Science. I love to write about Computer Informational blogs. Before write I did proper research on it. Hope you like our blogs. Thank you.

Related Posts

Leave a Reply

Your email address will not be published.