1arr_test = ["thetung1","thetung2","thetung3"]
2title = "thetung"
3if title not in arr_test:
4 arr_test.append(title)
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')
1if value in list:
2 #do stuff
3
4#Also to check if it doesn't contain
5if value not in list:
6 #do stuff
1# app.py
2
3listA = ['Stranger Things', 'S Education', 'Game of Thrones']
4
5if 'Dark' in listA:
6 print("Yes, 'S Eductation' found in List : ", listA)
7else:
8 print("Nope, 'Dark' not found in the list")
9
1'''
2 check if element NOT exist in list using 'in'
3'''
4if 'time' not in listOfStrings :
5 print("Yes, 'time' NOT found in List : " , listOfStrings)