check if array contains value python code example
Example 1: python check string not exist in array
arr_test = ["thetung1","thetung2","thetung3"]
title = "thetung"
if title not in arr_test:
arr_test.append(title)
Example 2: how to check if value is in list python
>>> letters = [a,b,c,d,e]
>>> 'a' in letters:
True
Example 3: if string is in array python
if item in my_list:
Example 4: python check if list contains value
if value in list:
if value not in list:
Example 5: extened array if value match python
for logs in mydir:
for line in mylog:
list1.append(line)
if any(True for line in list1 if "string" in line):
list2.extend(list1)
del list1
....
Example 6: how to check an array for a value in python
s = set(a)
if 7 in s: