What is the difference_update method in sets in python | How to use the difference_update method of sets?


This method is used to remove common items from set A, given that A.difference_update(B). All changes are done in the original set only no 3rd variable is involved in this method. Simply put, all it does is

A=A-B | All the operation done is stored in A itself.




All changes are done in the original set itself.

This method takes an argument


What is the difference_update method in sets



  1. A set is taken
  2. B set is taken
  3. difference_update() method is applied on set A using B
  4. Value of set A is printed


  1. A set is printed excluding common item from set B.

Interview Questions:

  • What is difference between difference method and update difference method?

Difference method apply changes and result is stored in another variable, whereas in difference update method applied changes is stored in original set itself.

Quick Links:

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. Required fields are marked *