I have two files: q.txt contains words and p.txt contains sentences. I need to check if any of the words in q.txt is present in p.txt. Following is what I wrote:
#!/usr/bin/python
twts=open('p.txt','r');
words=open('q.txt','r');
for wrd in words:
for iter in twts:
if (wrd in iter):
print "Found at line" +iter
It does not print the output even if there is a match. Also I could see that the outer for loop does not proceed to the next value in the words object. Could someone please explain what am I doing wrong here?
Edit 1: I'm using Python 2.7 Edit 2: Sorry I've mixed up the variable names. Have corrected it now.