how to check a value in list python code example
Example 1: how to check an element in a list in python
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist:
print("Yes, 'apple' is in the fruits list")
Example 2: how to check if element is in list python
'''
check if element NOT exist in list using 'in'
'''
if 'time' not in listOfStrings :
print("Yes, 'time' NOT found in List : " , listOfStrings)
Example 3: check if a number is in a list python
5 in [3, 4, 5, 6, 7]
9 in [3, 4, 5, 6, 7]