I need to read in a file and split it into lines. Then search for a start and an end word and print out all the words in between including the start and end words.
For example: (file)
a
b
foo
c
d
bar
e
output:
foo
c
d
bar
I tried to search on the web but without any luck.
I'm just a beginner, any help is appreciated thanks.
For example: (file)
a
b
foo
c
d
bar
e
output:
foo
c
d
bar
I tried to search on the web but without any luck.
I'm just a beginner, any help is appreciated thanks.
Code:
import re
f = open('input, 'r')
lines = f.readlines()
for line in lines:
#if line.startswith("main"):
# and endswith("end"):
print re.split(r"\s|," , line)
Comment