I am looping through the lines of a text document, trying to find the first blank line that occurs after another line (say line 100 for this example).
My code is:
BlankLines=[]
f=open(MyFile, 'r')
for num, line in enumerate(f):
if line=='\n' and num>100:
BlankLines.append(num)
Result=Blanklines[0]
There are multiple lines that meet this criteria, but I just want the first line that meets it. What is the most elegant way of doing this? Is there a way to do it without creating a list and then selecting the first element?
Thanks!