File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 11adder
22black
33crane
4- kanes
54learn
65quake
76snake
Original file line number Diff line number Diff line change 55
66def 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 )
You can’t perform that action at this time.
0 commit comments