Python set.intersection_update() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
set method

Definition

intersection_update(*others) removes from the set every item that is missing from at least one of the iterables you pass. What is left is the overlap. The set is changed in place.

It does the same job as intersection(), but instead of returning a new set it overwrites the original and returns None.

set.intersection_update() is an instance method of the built-in set type: call it on a set with dot notation, such as post_tags.intersection_update(...). No import is needed.

Syntax

Pass one or more iterables, and call it on its own line, because the return value is always None.

python
s.intersection_update(iterable)
s.intersection_update(iterable1, iterable2)
s &= other_set
CallWhat it does
{1, 2, 3}.intersection_update({2, 3, 4})Returns None; the set becomes {2, 3}.
{1, 2, 3}.intersection_update([3, 4], {3, 5})Returns None; the set becomes {3}, the only item present everywhere.
{1, 2}.intersection_update({3})Returns None; the set becomes set(), because nothing is shared.

s &= other has the same effect, but needs another set on the right. If you need to keep the original items, use intersection(), which returns a new set instead.

Method signatures
python
set.intersection_update(*others)
# returns: None; the set now holds only items present in every iterable
# raises: TypeError if an argument is not iterable or an item is unhashable

Parameters

ParameterDescription
*othersZero or more iterables: set, list, tuple, string, range, and so on. An item stays only if it appears in all of them.

Return Value

Return ValueDescription
NoneAlways None. The set itself is smaller, or empty (set()) when nothing is shared.

Python Examples

Example 1 — Keep Only the Approved Tags on a Post

Filter a tag set against an approved list, in place, and check what the method returns.

python
post_tags = {"python", "sets", "spam", "loops"}
approved = {"python", "sets", "loops", "dicts"}

print(post_tags.intersection_update(approved))
print(sorted(post_tags))
print(sorted(approved))

How It Works

  1. No return value. intersection_update() changes the set and returns None, which the first line prints.
  2. The spam tag is gone. "spam" is not on the approved list, so it is removed from the post's tags.
  3. The argument is not changed. The approved set still has four tags, including "dicts", which the post never used.

Example 2 — Narrow Down Hotels With Several Filters

Apply a list, a tuple, and a set as filters in one call, then narrow the result again.

python
hotels = {"Aqua", "Bay", "Cove", "Dune", "Edge"}
has_pool = ["Aqua", "Cove", "Dune", "Edge"]
near_beach = ("Bay", "Cove", "Edge")
cheap = {"Cove", "Edge", "Aqua"}

hotels.intersection_update(has_pool, near_beach, cheap)
print(sorted(hotels))

hotels.intersection_update(["Edge"])
print(hotels)

How It Works

  1. Three filters at once. A hotel must have a pool, be near the beach, and be cheap, so only Cove and Edge survive all three.
  2. Different kinds of filters. A list, a tuple, and a set are mixed in one call, which works because any iterable is accepted.
  3. A second pass. Narrowing to the list ["Edge"] leaves a set with a single item, which Python prints as {'Edge'}.

Example 3 — Trim a Team and See Who Else Notices

Compare a second name for the set, a copy, and the &= operator.

python
team = {"ann", "bo", "cy"}
same_team = team
backup = team.copy()

team.intersection_update({"bo", "cy", "di"})
print(sorted(same_team))
print(sorted(backup))

team &= {"cy"}
print(team, same_team is team)

How It Works

  1. Two names, one set. same_team refers to the very same set, so it also loses "ann", who is not in the argument.
  2. The copy is independent. backup was copied earlier, so it still lists all three people.
  3. The operator works in place too. team &= {"cy"} keeps only "cy" without making a new set, so same_team is team stays True.

Frequently Asked Questions

It removes every item that is not also found in all the arguments, changing the set in place. It returns None.
intersection() returns a new set and keeps the original. intersection_update() overwrites the original set and returns None.
They have the same effect, but the &= operator needs a set on the right. intersection_update() accepts any iterable and several arguments.
The set becomes empty and prints as set(). No error is raised.
No, the removed items are gone. Keep a copy with s.copy() first if you may need the original items later.

Next: set.isdisjoint()

Return True if the set and the other iterable share no items.

isdisjoint() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful