python - What wrong with this code? -


it's supposed assign line numbers variable , make assign global variable , print that.

bookstartline = none bookendline   = none   def grabline(currenturl):       ### blah blah defines lines     index=0     line in lines:         index+=1         if "*** start of project" in line:             currentbookstartline = index         if "*** end of project" in line:             currentbookendline = index       global bookstartline     global bookendline      bookstartline = currentbookstartline     bookendline   = currentbookendline   grabline('http://www.gutenberg.org/cache/epub/768/pg768.txt')   print(bookstartline) print(bookendline) 

try

global bookstartline global bookendline   def grabline(currenturl):     ### blah blah defines lines     currentbookstartline,currentbookendline = false,false #needed define these before use below     index,line in enumerate(lines,start=1): #start = 1 index gets 1 on first iteration         if "*** start of project" in line:             currentbookstartline = index         if "*** end of project" in line:             currentbookendline = index      bookstartline = currentbookstartline     bookendline   = currentbookendline   grabline('http://www.gutenberg.org/cache/epub/768/pg768.txt') #grabline not grabline  print(bookstartline) print(bookendline) 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -