Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. from string import ascii_uppercase
  2.  
  3. from PyDictionary import PyDictionary  # type: ignore
  4.  
  5. DICTIONARY = PyDictionary()
  6. WORD = "RAFT"
  7.  
  8.  
  9. def standardize(word):
  10.     return word.strip().upper()
  11.  
  12.  
  13. with open("./words.txt", "r") as f:
  14.     words = set(map(standardize, f.readlines()))
  15.  
  16. for letter_idx in range(len(WORD)):
  17.     new_word = list(WORD)
  18.     for sub in ascii_uppercase:
  19.         new_word[letter_idx] = sub
  20.         new_str = "".join(new_word)
  21.         if new_str in words:
  22.             print(new_str)
  23.             try:
  24.                 print(DICTIONARY.meaning(new_str))
  25.             except Exception:
  26.                 print("No meanings found")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement