I want to check if a string is in a text file. If it is, do X. If it\'s not, do Y. However, this code always returns True
for some reason. Can anyone see what i
I made a little function for this purpose. It searches for a word in the input file and then adds it to the output file.
def searcher(outf, inf, string):
with open(outf, 'a') as f1:
if string in open(inf).read():
f1.write(string)