Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Anagram Finder")
- print("This program allows you to type in a series of characters and then checks the English dictionary for words made up of those exact characters.")
- letters = []
- uniqueletters = []
- lettercount = []
- possiblewords = []
- for letter in range(9):
- currletter = input("Enter letter number "+str(letter+1)+"\n").upper()
- if currletter not in(letters):
- uniqueletters.append(currletter)
- lettercount.append(1)
- else:
- lettercount[letters.index(currletter)] += 1
- letters.append(currletter)
- print("All letters:")
- print("|C|O|U|N|T|D|O|W|N|")
- print("|"+"|".join(letters)+"|")
- letters.sort()
- oed = open("English Dictionary.txt").readlines()
- #Link to file of words: http://www.mieliestronk.com/corncob_caps.txt
- for line in oed:
- wordletters = []
- wordlettercount = []
- line = list(line[:-1])
- for unique in uniqueletters:
- wordletters.append(unique)
- wordlettercount.append(line.count(unique))
- StillOK = True
- for original, word in zip(lettercount, wordlettercount):
- if original < word:
- StillOK = False
- for entry in line:
- if entry not in wordletters:
- StillOK = False
- if StillOK == True:
- possiblewords.append("".join(line))
- print("\nPossible words you can make with the letters provided sorted by length:")
- possiblewords = reversed(sorted(possiblewords,key=len))
- print("\n".join(possiblewords))
Advertisement
Add Comment
Please, Sign In to add comment