- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

# Python program to find Intersection of two lists?

Intersection operation means, we have to take all the common elements from List1 and List 2 and all the elements store in another third list.

List1::[1,2,3] List2::[2,3,6] List3::[2,3]

## Algorithm

Step 1: input lists. Step 2: first traverse all the elements in the first list and check with the elements in the second list. Step 3: if the elements are matched then store in third list.

## Example code

#Intersection of two lists def intertwolist(A, B): C = [i for i in A if i in B] return C # Driver Code A=list() B=list() n=int(input("Enter the size of the List ::")) print("Enter the Element of first list::") for i in range(int(n)): k=int(input("")) A.append(k) print("Enter the Element of second list::") for i in range(int(n)): k=int(input("")) B.append(k) print("THE FINAL LIST IS ::>",intertwolist(A, B))

## Output

Enter the size of the List ::5 Enter the Element of first list:: 12 23 45 67 11 Enter the Element of second list:: 23 45 88 11 22 THE FINAL LIST IS ::> [23, 45, 11]

- Related Articles
- C# program to find Intersection of two lists
- Intersection of Two Linked Lists in Python
- Python - Intersection of multiple lists
- JavaScript Program for Finding Intersection of Two Sorted Linked Lists
- JavaScript Program for Finding Intersection Point of Two Linked Lists
- Python program to find Cartesian product of two lists
- Find the Intersection Point of Two Linked Lists in Java
- Intersection of Two Linked Lists in C++
- Python program to find Union of two or more Lists?
- Program to find union of two given linked lists in Python
- How to find the intersection between two or more lists in R?
- Program to find linked list intersection from two linked list in Python
- Python program to find missing and additional values in two lists?
- Program to find minimum difference between two elements from two lists in Python
- Golang program to find intersection of two sorted arrays using two pointer approach

Advertisements