I am looking for a specific string in a list; this string is part of a longer string.
Basically i loop trough a text file and add each string in a different element of a list. Now my objective is to scan the whole list to find out if any of the elements string contain a specific string.
example of the source file:
asfasdasdasd
asdasdasdasdasd mystring asdasdasdasd
asdasdasdasdasdasdadasdasdasdas
Now imagine that each of the 3 string is in an element of the list; and you want to know if the list has the string "my string" in any of it's elements (i don't need to know where is it, or how many occurrence of the string are in the list). I tried to get it with this, but it seems to not find any occurrence
work_list=["asfasdasdasd", "asdasdasdasd my string asdasdasdasd", "asdadadasdasdasdas"]
has_string=False
for item in work_list:
if "mystring" in work_list:
has_string=True
print "***Has string TRUE*****"
print " \n".join(work_list)
The output will be just the list, and the bool has_string stays False
Am I missing something or am using the in statement in the wrong way?