1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/bin/env python def find_jumble(jumble, word_file='/users/charleslsnyder/dictionary.txt'): #you have to reset the word file to your dictionary and path sorted_jumble = sort_chars(jumble) for dictword in open(word_file, 'r').xreadlines(): if sorted_jumble == sort_chars(dictword): yield dictword def sort_chars(word): w = list(word.strip().lower()) w.sort() return w while(1): inp = raw_input("Enter word: ") if not inp: break for ans in find_jumble(inp): print "Answer = ", ans |
Jumble.py
Reply