MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / get_random_word_from_file

Function get_random_word_from_file

HangMan/HangMan.py:17–20  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

15
16# Function to generate a random word from a file
17def get_random_word_from_file(filename):
18 with open(filename, "r") as file:
19 words = file.readlines()
20 return random.choice(words).strip().lower()
21
22def main():
23 secret_word = get_random_word_from_file("words.txt")

Callers 1

mainFunction · 0.85

Calls 1

stripMethod · 0.80

Tested by

no test coverage detected