GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Intersection() function Python - GeeksforGeeks Intersection() function PythonLast Updated : 18 Apr, 2026 The set.intersection() method in Python returns a new set containing only the elements that are common to all given sets. It compares two or more sets and keeps only shared values. The original sets remain unchanged. ![]() Example: In this example, common elements between two sets are found using intersection().
Output {2, 3}
Explanation: a.intersection(b) returns elements present in both sets, only 2 and 3 are common. Syntax
ExamplesExample 1: In this example, the intersection of two and three sets is calculated.
Output {4, 6}
{4, 6}
Explanation:
Example 2: Here, the & operator is used as a shortcut for intersection.
Output {4, 6}
set()
set()
Explanation:
Example 3: In this example, intersection() is compared with symmetric_difference().
Output {4, 6}
{2, 5, 7, 8}
Explanation:
Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |