Hi, just beginning to learn Python, and am trying to create a script that will output matches from a text file to a user's input, I have managed that so far, the problem I have is trying to have something returned if the user puts in a string of text that does not match what is in the text file. ie - number not found. I have tried 'else', but it didn't work, I think I had put it in the wrong place.
Here's where I am at -
print"\nSEARCHING NUMBERS"
print "\nPlease Enter the Room Number 1, 2, 3, 4 or 5."
text_file = open("read_it.txt", "r")
word = raw_input("Type the Number you want to check: ")
word = word.upper()
print "\nnumber."
for line in text_file:
# if the line does not contain the typed word
# then continue to the next line
if ''.join(line).find(word) == -1:continue
print line
print
if ''.join(line).find(word) != 1:
print line
print
for line in text_file:
print line
raw_input("\n\nPress the enter key to exit.")
text_file.close()
Any help/suggestions greatly appreciated.
M :-/