def findLast(filename,key):
infile = open(filename,"r")
outfile = open("result.txt","w")
text = infile.read()
position = text.find(key)
if position == -1:
outfile.write(key + " is not found.\n")
else:
outfile.write(key + " is at " + str(position) + ".\n")
outfile.close()
infile.close()
print("Done")
위 함수는 첫 번째 문자열만 찾는 함수입니다. 혹시 여기서 while 함수를 사용해서 마지막 문자열만 찾는 함수는 어떻게 만들 수 있을까요 ㅠ