Skip to content

Commit 5548708

Browse files
committed
TR/DR updates
1 parent 9051820 commit 5548708

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

python-wordle/source_code_step_2/wordlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
adder
22
black
33
crane
4-
kanes
54
learn
65
quake
76
snake

python-wordle/source_code_step_3/wyrdl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
def main():
77
# Pre-process
8-
word = get_random_word()
8+
words_path = pathlib.Path(__file__).parent / "wordlist.txt"
9+
word = get_random_word(words_path.read_text(encoding="utf-8").split("\n"))
910

1011
# Process (main loop)
1112
for guess_num in range(1, 7):
@@ -20,11 +21,10 @@ def main():
2021
game_over(word)
2122

2223

23-
def get_random_word():
24-
wordlist = pathlib.Path(__file__).parent / "wordlist.txt"
24+
def get_random_word(word_list):
2525
words = [
2626
word.upper()
27-
for word in wordlist.read_text(encoding="utf-8").split("\n")
27+
for word in word_list
2828
if len(word) == 5 and all(letter in ascii_letters for letter in word)
2929
]
3030
return random.choice(words)

0 commit comments

Comments
 (0)