Last updated on: November 8, 2025
In this tutorial, we will discuss the commonly used methods for intersecting any two lists in the Python programming language, along with a sample example & its output.
The list is one of the essential built-in data types in the Python program that works as a complete Data Structure.
In this structure, one can add different data types simultaneously, such as numbers, Strings, and other lists. The intersection of two objects refers to the specific point where they align with each other.
In simple terms, the two objects with everyday belongings will be marked at their point of intersection. The same thing happens for the list in the Python program as well.
Explore: Python Glossary: 150+ Key Terms and Definitions Explained
How To Find The Intersection Of Two Lists In Python
Consider the following example where two lists are declared with some values.
L1 = [1, 2, 3] # First List Declaration L2 = [3, 4, 5] # Second List Declaration
In this case, the intersection point will be [3]. Because the number [3] is common in both lists declared. The ways to find an intersection of two lists are listed below:
- Using Counter() Method
- Using the Loop Method
- Using Set() Method
Let us explore each method with a sample example & its output.
Method 1: Find Out The Intersection Of Two Lists Using Counter() Method
The collection is an essential package with some built-in functions in the Python program. A similar built-in function is the Counter() method. The counter method takes the object name, in this case, the list name & finds out similarities.
Below are the steps that were used to implement the program:
- First, import the necessary collection package in the program to use the counter() method.
- Two different lists have been declared in the program, along with some values.
- The intersection point between those two lists will be received using the counter() method. And the result will be stored.
- The result will now be converted to a list & printed in the program.
Code:
import collections # Importing Collections
l1 = [10, 20, 30, 40] # Declaration Of First List
l2 = [30, 40, 50, 60] # Declaration Of Second List
# Getting The Intersection Point
res = collections.Counter(l1) & collections.Counter(l2)
print("The Intersection Point Is: ",list(res.elements()))
You may be familiar with the code where we saw printing values using the Counter() method.
Now, let us examine the output of the above code snippet to understand the implementation process of the counter() method.
Output:
The Intersection Point Is: [30, 40] …Program finished with exit code 0 Press ENTER to exit console.
Method 2: Find Out The Intersection Of Two Lists Using The Loop Method
The concept is to use the one-loop method along with one conditional statement. The loop will check each & every element of the list. If the same element is present in both lists, then it will be added to one empty list.
Below are the steps that were used to implement the program:
- Two Lists have been declared with string values in them.
- One loop is implemented for each list to check the first element.
- Within that list, the conditional statement is used to check for the presence of the same component in the second list.
- If the element exists in the second list, it will be added to the empty list. Otherwise, the for loop will execute the next iteration.
- That declared empty list will now be printed in the program.
Code:
l1 = ["C", "C++", "Java"] # Declaration Of First List
l2 = ["C++", "Java", "Python"] # Declaration Of Second List
res = [] # Empty List
for ele in l1: # For Loop Implementation
if ele in l2:
res.append(ele) # Adding Elements
print("The Intersection Point Is: " ,res)
Let us examine the output of the above code snippet to understand the loop method implementation process.
Output:
The Intersection Point Is: [‘C++’, ‘Java’] …Program finished with exit code 0 Press ENTER to exit console.
Method 3: Find Out The Intersection Of Two Lists Using the Set() Method
The set() method is another built-in function in the Python programming language developed to handle such mathematical issues.
To use the set() method, we don’t have to import any packages into the program; it will usually work.
Below are the steps that were used to implement the program:
- Two lists have been declared with some random integer values that share some commonalities.
- Now, in one separate variable, use the set method. Use the set() method to combine two lists & join them with the logical AND operator. It will help to get the common values.
- The data will be converted to a list in the same statement. The result will now be printed in the program.
Code:
l1 = [10, 20, 30, 60] # Declaration Of First List
l2 = [30, 40, 50, 60] # Declaration Of Second List
res = list(set(l1) & set(l2)) # Implementing Set To Get Intersection
print("The Intersection Point Is: ", res)
Let us examine the output of the above code snippet to understand the implementation process of the set() method.
Output:
The Intersection Point Is: [60, 30] …Program finished with exit code 0 Press ENTER to exit console.
Conclusion
As we saw, finding the intersection of any two lists is very easy. You need to have a basic knowledge of Python programming.
In this article, we discuss three easy methods for finding the intersection of two lists in Python. The intersection of any two lists can be found in the elements they share.
As per your choice, you can select any one of the methods & start practicing it. It will help you in the future.

