I have this code:
b = str(raw_input('please enter a book '))
searchfile = open("txt.txt", "r")
for line in searchfile:
if b in line:
print line
break
else:
print 'Please try again'
This works for what I want to do, but I was wanting to improve on it by repeating the loop if it goes to the else
statement. I have tried running it through a while loop but then it says 'line' is not defined
, any help would be appreciated.