{"id":25058,"date":"2021-11-10T09:37:32","date_gmt":"2021-11-10T04:07:32","guid":{"rendered":"https:\/\/python-programs.com\/?p=25058"},"modified":"2021-11-10T09:37:32","modified_gmt":"2021-11-10T04:07:32","slug":"python-set-intersection_update-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-set-intersection_update-method-with-examples\/","title":{"rendered":"Python Set intersection_update() Method with Examples"},"content":{"rendered":"
Prerequisite:<\/h5>\n

Python set() Function with Examples<\/span><\/a><\/p>\n

Set intersection_update() Method in Python:<\/strong><\/p>\n

The intersection_update() method removes items that do not appear in both sets (or in all sets if the comparison is done between more than two sets).<\/p>\n

The intersection_update() method differs from the intersection() method in that the former returns a new set without the unwanted items, whereas the latter removes the unwanted items from the original set.<\/p>\n

Syntax:<\/strong><\/p>\n

set.intersection_update(set1, set2,.....)<\/pre>\n

Parameters<\/strong><\/p>\n

set1:<\/strong> This is Required. The set to look for items that are similar in<\/p>\n

set2:<\/strong> This is Optional. The other set to look for similar items in. You are free to compare as many sets as you want. Use a comma to separate the sets.<\/p>\n

Return Value:<\/strong><\/p>\n

None is returned by this method (meaning it does not have a return value). It only calls the intersection_update() method to update the set.<\/p>\n

Let P, Q, R be three sets<\/p>\n

When you execute the code,<\/p>\n