Well this is simple.
Ill only do it for the First File, but to show how many times it comes up, you can count, but this is a one word per line test.
import os
file1 = open("file1.txt", "r") # Make sure you added the keywords in beforehand
file2 = open("file2.txt", "r") #These will open the file ready for use.
step1 = file1.readlines()
step2 = file2.readlines()
pos1 = 0
for line in step1:
test = line.find('hello')
print(test)
This will print:
0
0
0
-1
0 being found and -1 being not found with File 1 having the following words put into it.REMEMBER it reads each line seperately, so if you have multiple per line it might not work.
Hello
Hello
Hello
Bye
Good Luck, Msg me if u have any problems.
5
solved How to search for each keyword from file1 in file2 and return the number of times it was found? [closed]