It is easy to check if an element of a list is in another list using any():
any()
any(elem in list2 for elem in list1)
but is there
Use a list comprehension:
[elem for elem in list1 if elem in list2]
Example:
list1 = [1, 2, 3, 4, 5] list2 = [1, 10, 2, 20] c = [elem for elem in list1 if elem in list2] print(c)
Output
[1, 2]