My daughter plays FaceBook games and is always asking me to solve anagrams. So I thought I would make a script for her to enter a scrambled word and it would compare it to the built-in spell check dictionary. But this code returns words such as quip and quiz when I enter 'quit' as a test word. What am I doing wrong?
infile = open ("/usr/share/dict/american-english", "r")
dict = infile.readlines()
scrambled = raw_input("Enter the scrambled word: ")
for word in dict:
word = word.strip()
if len(word) == len(scrambled):
for letter in scrambled:
if letter not in word:
break
print word
infile is the path to your on-board spell-checking dict.