Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 4cc178c

Browse files
committed
-Changed to list of word in json format
-Changed the way to get the word from json in hangman.py
1 parent 34514d9 commit 4cc178c

File tree

3 files changed

+1425
-1422
lines changed

3 files changed

+1425
-1422
lines changed

projects/Terminal_Based_Hangman_Game/hangman.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import random
2-
from words import word_list
3-
2+
import json
43

54
#function to randomly get one word from words.py and convert the word to uppercase
65
def get_word():
7-
word = random.choice(word_list)
6+
with open('words.json') as json_file:
7+
data = json.load(json_file)
8+
9+
wordArray = data["word_list"]
10+
word = random.choice(wordArray)
811
return word.upper()
912

1013
#function to play the game

0 commit comments

Comments
 (0)