1## checking any elment of list_B in list_A
2list_A = [1, 2, 3, 4]
3
4list_B = [2, 3, 6]
5
6check = any(item in list_A for item in list_B)
7
8print(check)
9# True
1## checking all elements of list_B in list_A
2list_A = [1, 2, 3, 4]
3list_B = [2, 3]
4
5check = all(item in list_A for item in list_B)
6
7print(check)
8# True
1>>> items = set([-1, 0, 1, 2])
2>>> set([1, 2]).issubset(items)
3True
4>>> set([1, 3]).issubset(items)
5False
6
1'''
2 check if list1 contains any elements of list2
3'''
4result = any(elem in list1 for elem in list2)
5if result:
6 print("Yes, list1 contains any elements of list2")
7else :
8 print("No, list1 contains any elements of list2")
1##Taking examples of two python lists.
2
3##Take examples of two lists.
4
5list1 = [2,4,0,7,6]
6list2 = [1,0,9,7,6]
7
8##the statement for condition is.
9
10check = any(element in list2 for element in list1)
1## using set
2list_A = [1, 2, 3, 4]
3list_B = [2, 3]
4
5set_A = set(list_A)
6set_B = set(list_B)
7
8print(set_A.intersection(set_B))
9
10# True if there is any element same
11# False if there is no element same