Most Unix(-like) systems have a file named /usr/share/dict/words, this file contains a list of (english) dictionary words. You can read it into a list and use this list to generate a random word

words = []
with open('/usr/share/dict/words') as f:
    for line in f:
        words.append(line.strip())
import random
random.choice(words)
Answer from Iain Shelvington on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 53144329
python - wordList - Hangman game - Stack Overflow
newword = getRandomWord(words.split()) will create a new random word. You might want to read about pyhton style guide at python.org/dev/peps/pep-0008 - your naming conventions are off.
🌐
GitHub
gist.github.com › nicolasfig › 3903059
Hangman game using random and indexing · GitHub
Hangman game using random and indexing. GitHub Gist: instantly share code, notes, and snippets.
🌐
Towards Data Science
towardsdatascience.com › home › latest › implementing the hangman game in python
Implementing the Hangman Game in Python | Towards Data Science
August 28, 2025 - For this purpose, we will need both a list of words from which the computer picks one word to be guessed, and a Python function called random, which will randomly pick out that word from the given list. To generate the list, I googled the 100 most common nouns used in the English language and found a list.
🌐
CodePal
codepal.ai › code-generator › query › ThGPeyMY › python-function-generate-random-word-hangman
Generate Random Word for Hangman - CodePal
import random def make_hangman(): """ This function generates a random word for the game Hangman. Returns: str: A random word for the game Hangman """ try: # List of words for the game words = ["hangman", "python", "code", "programming", "computer"] ...
Top answer
1 of 8
122

Reading a local word list

If you're doing this repeatedly, I would download it locally and pull from the local file. *nix users can use /usr/share/dict/words.

Example:

word_file = "/usr/share/dict/words"
WORDS = open(word_file).read().splitlines()

Pulling from a remote dictionary

If you want to pull from a remote dictionary, here are a couple of ways. The requests library makes this really easy (you'll have to pip install requests):

import requests

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = requests.get(word_site)
WORDS = response.content.splitlines()

Alternatively, you can use the built in urllib2.

import urllib2

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = urllib2.urlopen(word_site)
txt = response.read()
WORDS = txt.splitlines()
2 of 8
20

Solution for Python 3

For Python3 the following code grabs the word list from the web and returns a list. Answer based on accepted answer above by Kyle Kelley.

import urllib.request

word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urllib.request.urlopen(word_url)
long_txt = response.read().decode()
words = long_txt.splitlines()

Output:

>>> words
['a', 'AAA', 'AAAS', 'aardvark', 'Aarhus', 'Aaron', 'ABA', 'Ababa',
 'aback', 'abacus', 'abalone', 'abandon', 'abase', 'abash', 'abate',
 'abbas', 'abbe', 'abbey', 'abbot', 'Abbott', 'abbreviate', ... ]

And to generate (because it was my objective) a list of 1) upper case only words, 2) only "name like" words, and 3) a sort-of-realistic-but-fun sounding random name:

import random
upper_words = [word for word in words if word[0].isupper()]
name_words  = [word for word in upper_words if not word.isupper()]
rand_name   = ' '.join([name_words[random.randint(0, len(name_words))] for i in range(2)])

And some random names:

>>> for n in range(10):
        ' '.join([name_words[random.randint(0,len(name_words))] for i in range(2)])

    'Semiramis Sicilian'
    'Julius Genevieve'
    'Rwanda Cohn'
    'Quito Sutherland'
    'Eocene Wheller'
    'Olav Jove'
    'Weldon Pappas'
    'Vienna Leyden'
    'Io Dave'
    'Schwartz Stromberg'
🌐
Invent with Python
inventwithpython.com › chapter9.html
Chapter 9 - Extending Hangman
This way, the player will know if the secret word is an animal, color, shape, or fruit. Here is the original code: 91. while True: 92. displayBoard(missedLetters, correctLetters, secretWord) In your new version of Hangman, add line 124 so your program looks like this:
Find elsewhere
🌐
GitHub
github.com › Vickyabiodun › Hangman-Game
GitHub - Vickyabiodun/Hangman-Game: Hangman Game
chosen_word = random.choice(hangman_words.word_list) We will also need to know the length of the chosen word, so we will store it in a variable called word_length:
Author   Vickyabiodun
🌐
MakeUseOf
makeuseof.com › home › programming › how to create a hangman game using python
How to Create a Hangman Game Using Python
August 1, 2023 - Declare a function, start_hangman_game(), that defines the main logic of the program. Get a random word by calling the get_random_word_from_wordlist() function and get the sequence to display to the user using the get_some_letters() function.
🌐
Python Geeks
pythongeeks.org › python geeks › python projects › python hangman – word guessing game program
Python Hangman - Word Guessing Game Program - Python Geeks
March 28, 2022 - Below are the steps to develop python word guessing hangman game: 1. Importing Modules random and tkinter 2. Creating main loop 3. Creating the dashes of secret word 4. Creating letters icon images and Hangman images. 5. Placing letters icon and hangman image on the gaming screen 6.
🌐
GeeksforGeeks
geeksforgeeks.org › hangman-game-in-python
Hangman Game in Python - GeeksforGeeks
July 29, 2025 - This is the text file used inside the code words.txt, which contains 50,000 English words. ... # Python program to implement Hangman Game stages = [''' +---+ | | O | /|\ | / \ | | ========= ''', ''' +---+ | | O | /|\ | / | | ========= ''', ''' +---+ | | O | /|\ | | | ========= ''', ''' +---+ | | O | /| | | | =========''', ''' +---+ | | O | | | | | ========= ''', ''' +---+ | | O | | | | ========= ''', ''' +---+ | | | | | | ========= '''] import random import words # Function to randomly select a word from dictionary def get_word(): # Path to the text file with open('/GeeksforGeeks/Hangman/words.txt', 'r') as f: # Reads each word after splitting words1 = f.read().splitlines() # Returns any random word return random.choice(words1) def hangman(): # randomly chose a word form the list of words.
🌐
CodeChef
codechef.com › learn › course › python-projects › PYPROJ5 › problems › PYHANG03
Hangman - Random Word in Python Projects for Beginners:
Test your Python Projects for Beginners: knowledge with our Hangman - Random Word practice problem. Dive into the world of python-projects challenges at CodeChef.
🌐
Medium
medium.com › @smhashirashfaq › how-to-create-your-own-hang-man-game-using-python-e93f2686b33d
how to create your own hang man game using python | by Hashir Ashfaq | Medium
March 20, 2023 - words = ['python', 'java', 'javascript', 'php', 'ruby', 'csharp', 'swift', 'kotlin'] ... Using the random library, we will select a random word from the list of words.
🌐
GitHub
github.com › Johongirrr › hangman
GitHub - Johongirrr/hangman: Random word generator for guessing · GitHub
Random word generator for guessing. Contribute to Johongirrr/hangman development by creating an account on GitHub.
Author   Johongirrr
🌐
Codefinity
codefinity.com › courses › v2 › 6f64c971-14d4-4361-895d-2052fa4b0190 › 186f618c-3294-4ea4-9de3-5d4d9d4d973d › e34e98f5-a158-4fcb-aa4b-91c09b878e63
Learn Random Word Generator | Hangman Game
To do that, we create the choose_word_random function. ... Define the function choose_word_random with word_list as a parameter. Inside the function, return a randomly selected word from word_list using the random.choice(...) method. ... Thanks for your feedback!
🌐
Practice Python
practicepython.org › solution › 2016 › 10 › 15 › 30-pick-word-solutions.html
30 Pick Word Solutions
October 15, 2016 - This exercise is Part 1 of 3 of the Hangman exercise series. The other exercises are: Part 2 and Part 3. In this exercise, the task is to write a function that picks a random word from a list of words from the SOWPODS dictionary. Download this file and save it in the same directory as your ...
🌐
Codefinity
codefinity.com › courses › projects › 6f64c971-14d4-4361-895d-2052fa4b0190 › 186f618c-3294-4ea4-9de3-5d4d9d4d973d › e34e98f5-a158-4fcb-aa4b-91c09b878e63
Learn Random Word Generator | Crafting a Classic Hangman Game
To do that, we create the choose_word_random function. ... Define the function choose_word_random with word_list as a parameter. Inside the function, return a randomly selected word from word_list using the random.choice(...) method.