I searched daniweb for related questions and google but i canot seem to find my problem in my code
When I try to search for a word that exists in my list it returns false
This is my code
def main():
#the word that I am looking for
word = "fox"
#opening my dictionary file
dict = open("src/DictionaryE.txt","r")
#add the file to a list
for i in dict:
list =[]
#geting rid of formating
i=i.strip()
list.append(i)
print list
#searching for the word in list
if word in list:
#if the word is in the list print it
print word
else:
print "You typed a word that dosen't exist"
main()
My dictionary is a simple txt file with 3 words
bear
wolf
fox
Oh and the txt file is read and printed correctly so no I/O error
If any one knows whatI am doing wrong please tell me
Thank you