forked from devs-nest/hangman-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
words.py
31 lines (24 loc) · 878 Bytes
/
words.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import random
def load_words():
"""
this function help to load more word by updating word_list (list)
Example :-
word_list = ["learning", "kindness", "joy", "kiet", "good"] (old)
word_list = ["learning", "kindness", "joy", "kiet", "good" ,"hello"] (new)
"""
word_list = ["learning", "kindness", "joy", "kiet", "good"]
# uncomment the below for testing
# WORDLIST_FILENAME = "words.txt"
# inFile = open(WORDLIST_FILENAME, 'r', 0)
# line = inFile.readline()
# word_list = string.split(line)
return word_list
def choose_word():
"""
word_list (list): list of words (strings)
this function return one random world from list
"""
word_list = load_words()
secret_word = random.choice(word_list)
secret_word = secret_word.lower()
return secret_word