I need to find a way to print "Cannot find birthday" if the "searchline" is not found in the "pidigits" file. Maybe using a count somehow. I've tried a lot of different things, but I cannot figure it out. I have attached both files.
import string
def find():
blength = len(open("birthday.txt").readlines())
length = len(open("pidigits.txt").readlines())
inBirthday = open("birthday.txt", "r")
search = 0
for line in range(blength):
inPiDigits = open("pidigits.txt", "r")
if search < 0:
print "Cannot Find Birthday."
searchline = inBirthday.readline()
L1 = inPiDigits.readline()
for lines in range(length):
L2 = inPiDigits.readline()
linePiDigits = L1[:50]+L2[:-46]
search = linePiDigits.find(searchline[:6])
L1 = L2
count +=1
if search >=0:
print "Searching for:",searchline,"line",lines+1,"character position",search
print
inPiDigits.close
find()