If I have this line
"he is a good man and he goes every day to a school"
And I want to detect what is between the two words "he""and", so the output will be
is a good man
I tried this
for line in file:
print line[line.index('he'): line.index('and')]
This code gives the output
he is a good man
How can I do that?