the_grayhatter
New member
The program is supposed to go into a text file and test to see if a certain word is present. It works, but the only problem is that even if part of a word is present it will say the word is there. For example: if I try and search for "eable" it will say it found it because the word "seeable" is there. How can I fix this?
Here's the script:
import string
import math
while 1:
print ""
print "W"*80
x = raw_input('What word would you like to search for: ')
wordlist = open('list.txt', 'r')
line = wordlist.read()
wordlist.close
search = str(x)
index = line.find(search)
if index > 0:
print "\n" + x + " was found!\n"
else:
print "\nnot found!\n"
print "W"*80
y = raw_input('Enter 1 to try again, or enter 0 to quit: ')
if y == '0': break
Here's the script:
import string
import math
while 1:
print ""
print "W"*80
x = raw_input('What word would you like to search for: ')
wordlist = open('list.txt', 'r')
line = wordlist.read()
wordlist.close
search = str(x)
index = line.find(search)
if index > 0:
print "\n" + x + " was found!\n"
else:
print "\nnot found!\n"
print "W"*80
y = raw_input('Enter 1 to try again, or enter 0 to quit: ')
if y == '0': break