-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_scrabble_words
More file actions
23 lines (21 loc) · 917 Bytes
/
find_scrabble_words
File metadata and controls
23 lines (21 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
file_in = open("your_filename_here.txt")
def check_word(word, letters):
"Function will check the letters in your tray vs. how many are in the word AND if they're even in the word."
for letter in word:
if letter not in letters or word.count(letter) != letters.count(letter):
return False
return True
def print_scrabble_words(text, letters):
"Function that will find all possible words out of a text file that match the letters string arguments."
total, excluded, usable = 0, 0, 0
for line in text:
total += 1
word = line.strip()
if check_word(word, letters): # Goto check_word function with your word and letters (BOTH) string arguments.
print(word)
usable += 1
else:
excluded += 1
print("Total words: ", total)
print("Total words excluded: ", excluded)
print("Total usable words: ", usable)