Created
February 27, 2018 12:47
-
-
Save umair-tp/0c4001e39ad0933e5bdc6c009b258fd3 to your computer and use it in GitHub Desktop.
Exercise 30 : 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 c…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| with open('sowpods.txt') as dict_file: | |
| words_list = dict_file.read().split('\n') | |
| print words_list[random.randint(0, len(words_list))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment