From 42368b7349e63d43a46ace9af6dec783cfd075f9 Mon Sep 17 00:00:00 2001 From: Big Date: Thu, 6 Oct 2022 01:31:27 +0700 Subject: [PATCH] add get_wordlist increase wordlist from 8 to 10k --- Games/hangman.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Games/hangman.py b/Games/hangman.py index cdab9d6..6487040 100644 --- a/Games/hangman.py +++ b/Games/hangman.py @@ -1,7 +1,15 @@ import random import sys +import urllib.request -listword=["hello","computer","python","java","html","world","apple","windows"] +def get_wordlist(): + word_url = "https://www.mit.edu/~ecprice/wordlist.10000" + response = urllib.request.urlopen(word_url) + long_txt = response.read().decode() + words_list = long_txt.splitlines() + return words_list + +listword = get_wordlist() guessword=[] random_word=random.choice(listword)