1thislist = ["apple", "banana", "cherry"]
2if "apple" in thislist:
3 print("Yes, 'apple' is in the fruits list")
1# checking all elements of list_B in list_A
2list_A = [1, 2, 3, 4]
3list_B = [2, 3]
4
5check = any(item in list_A for item in list_B)
6
7print(check)
8# True
1thelist = ["apple", "avocado", "banana"]
2
3inpt = input("Check an item in the list: ")
4
5if inpt in thelist:
6 print(inpt, "is in the list!")
1# To check if a certain element is contained in a list use 'in'
2bikes = ['trek', 'redline', 'giant']
3'trek' in bikes
4# Output:
5# True
1listA = [item1, item2, item3]
2if item4 in listA:
3 print('yes, item4 is in the list')
4else:
5 print('no, item4 is not in the list')