I need to look for a list of words in a document. However, when I run my code it seems to only iterate over the first word. I know it has something to do with my while(s)
loop, but I just can't seem to get it to work. Also, yes the words are in the document.
How do I apply the code to each word in the list?
file = open('DOG2.txt', 'r')
word = ['cat','dog','Yellow']
s = " "
count=1
for p in word:
while(s):
s = file.readline()
L = s.split()
if p in L:
print("Line Number:",file.name,p,count,":",s)
count+=1