import time
with open('txt.txt', 'r') as myfile:
data=myfile.read().replace('\n', '')
pdf_content = data.split(" ")`
vocab = input('Vocab word to search for: ')
if vocab not in pdf_content:
print('word not found....')
if vocab in pdf_content:
for vocab in pdf_content:
print((" ".join(pdf_content[1])))
time.sleep(200)
I want to basically search a body of text for a certain word and return a group of words around that 1 word.
ex. your paragraph is the quick brown fox jumped over the lazy dog and we wanted to search for brown, it would return quick brown fox since those are the surrounding words. I'm not sure how to do this but help would be greatly appreciated