I have 2 elements for example 1 and 2. I need to find out if both of these elements are in my array.
For example: I have 1,2,3,4. And i have Array [2,3,4,111]. If all my elements are in the array, then it's True, else False
I have 2 elements for example 1 and 2. I need to find out if both of these elements are in my array.
For example: I have 1,2,3,4. And i have Array [2,3,4,111]. If all my elements are in the array, then it's True, else False
array = [2,3,4,111]
elements_to_check = [2,3]
result = set(elements_to_check).issubset(array)
print(result)
Prints True
if elements_to_check = [2,3]
Prints False
if elements_to_check e.g. = [2,3,5]
Another solution would be
list = [2,3,4,111]
elements_to_check = [1,2]
result = len([x for x in elements_to_check if x in list]) == len(elements_to_check)
Prints True if elements_to_check = [2,3]
Prints False if elements_to_check e.g. = [1,2]