Read a file line by line and check for a certain word. If the word is found, print that the word was found. If the word is not found, print that the word was not found.
Problem im having:
I receive both print messages instead of one.
if message.body.startswith("!check"): with open('data/name.txt', 'r') as inF: for line in inF: if "apple" in line: print("an apple was found") else: if not "apple" in line: print("No apple was found")
The text document looks like:
apple banana carrot watermelon human
Thanks in advance if anyone can help />