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 Python code. This file is Peter Norvig’s compilation of the dictionary of words used in professional Scrabble tournaments. Each line in the file contains a single word.
Hint: use the Python random library for picking a random word.
To solve this exercise, you need to do three things:
Read all the lists of words
Generate a random number
Take that word
Here is a sample solution:
Here is an alternate approach, with some comments:
There are many solutions to every problem. Enjoy hacking around to find another solution!