python check list in list another code example
Example 1: check if a list contains an item from another list python
## checking any elment of list_B in list_A
list_A = [1, 2, 3, 4]
list_B = [2, 3, 6]
check = any(item in list_A for item in list_B)
print(check)
# True
Example 2: check if part of list is in another list python
'''
check if list1 contains any elements of list2
'''
result = any(elem in list1 for elem in list2)
if result:
print("Yes, list1 contains any elements of list2")
else :
print("No, list1 contains any elements of list2")