set.intersection()
set.intersection() is a Python method in the Set Methods category. Returns a new set with elements common to the set and all others (& operator). The syntax is set.intersection(*others). Returns: New set. A typical example: {1, 2, 3}.intersection({2, 3, 4}) # {2, 3}
{1, 2} & {2, 3} & {3, 4} # set(). A close sibling is set.add(), which adds an element to the set if not already present. A close sibling is set.remove(), which removes element x; raises KeyError if not found. A close sibling is set.discard(), which removes element x if present (does nothing if not found). A close sibling is set.pop(), which removes and returns an arbitrary element. Raises KeyError if empty. More about this category: Set methods for collection operations — union, intersection, difference, and more. For a broader walkthrough, read the Set Methods guide. Related Set Methods entries: set.add(), set.remove(), set.discard(), set.pop(), set.clear(), set.union().