if in list code example
Example 1: how to check if any item in list is in anoter list
# checking all elements of list_B in list_A
list_A = [1, 2, 3, 4]
list_B = [2, 3]
check = any(item in list_A for item in list_B)
print(check)
# True
Example 2: Check if element in list Python
listA = [item1, item2, item3]
if item4 in listA:
print(
else:
print(
Example 3: python check if list contains value
if value in list:
#do stuff
#Also to check if it doesn
if value not in list:
#do stuff
Example 4: check if list contains string python
some_list = [
if any("abc" in s for s in some_list):
# whatever