How to find common elements between two lists in Python

Two lists can share common elements between them. For example, 1 is a common element between [1, 2] and [1, 3].

Solution for How to find common elements between two lists in Python : You can use set.intersection() to find common elements between two lists Use set() to convert one of the lists to a set. Call set.intersection(*s) on this new set with the other list as *s to find common elements between them. Use list(iterable) to convert the resultant set of common elements to a list.


how-to-find-common-elements-between-two-lists-in-python