antar2 wrote: > I am a starter in python and would like to write a program that reads > lines starting with a line that contains a certain word. > For example the program starts reading the program when a line is > encountered that contains 'item 1' > > > The weather is nice > Item 1 > We will go to the seaside > ... > > Only the lines coming after Item 1 should be read
Start reading each line, and skip them until your criterion matches. Like this: def line_skipper(predicate, line_iterable): for line in line_iterable: if predicate(line): break for line in line_iterable: yield line Diez -- http://mail.python.org/mailman/listinfo/python-list