python if any in list code example
Example 1: check if anything in a list is in a string python
y = any(x in String for x in List)
Example 2: 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 3: Check if element in list Python
listA = [item1, item2, item3]
if item4 in listA:
print(
else:
print(
Example 4: python check if list contains
# To check if a certain element is contained in a list use
bikes = [
# Output:
# True
Example 5: how to check if element is in list python
check if element NOT exist in list using
if
print("Yes, 'time' NOT found in List : " , listOfStrings)
Example 6: python find if element in list
element_you_want_to_find in list_in_you_want_to_search
Note: Don
Conclusion: Use the in operator