how to look for a word in a file python code example
Example 1: how to check for a particular word in a text file using python
file = open("search.txt")
print(file.read())
search_word = input("enter a word you want to search in file: ")
if(search_word in file.read()):
print("word found")
else:
print("word not found")
Example 2: how to find word in file python
with open('example.txt') as f:
if 'blabla' in f.read():
print("true")