Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Hex Word Finder
- This program searches a text file for any words that are made up entirely of the letters available in HEX, ABCDEFG.
- """
- filename = input("Please enter the name of a text file and it's location if it is not in the root directory. You don't need to write '.txt'.\n")
- dictionary = open(filename+".txt","r")
- currword = []
- lensixwords = []
- allhexwords = []
- for char in dictionary.read():
- if char.isalpha() == True:
- currword.append(char)
- else:
- currword = "".join(currword)
- currword = currword.upper()
- A = currword.count("A")
- B = currword.count("B")
- C = currword.count("C")
- D = currword.count("D")
- E = currword.count("E")
- F = currword.count("F")
- if (A+B+C+D+E+F) == len(currword):
- if currword not in allhexwords:
- allhexwords.append(currword)
- print("word found:",currword)
- if len(currword) == 6:
- lensixwords.append(currword)
- currword = []
- else:
- currword = []
- allhexwords.sort()
- lensixwords.sort()
- output1 = open("Hex Word Dictionary.txt","w")
- for word in allhexwords:
- output1.write(word+"\n")
- output2 = open("Six Letter Hex Word Dictionary.txt","w")
- for word in lensixwords:
- output2.write(word+"\n")
- dictionary.close()
- output1.close()
- output2.close()
- print("\nAlphabetically ordered dictionary of hex words saved.")
- print("Please open newly created text files in the root folder.")
Advertisement
Add Comment
Please, Sign In to add comment