I have a gigantic txt file that I read in and cleaned into a list.
I'm looking for certain words, so I wrote a quick function
def find_words(lines):
for line in lines:
if "my words" in line:
print(line)
which works fine, but how would I write the function so that it prints the word, plus the following next 50 lines or so? Summarizing, I want to find the text that comes after that word.
From then, I would want to create an empty df, and have the function fill in the df with a new row with the word + next 50 rows, every time it found that word.