Skip to content

Instantly share code, notes, and snippets.

@umair-tp
Created February 27, 2018 12:47
Show Gist options
  • Select an option

  • Save umair-tp/0c4001e39ad0933e5bdc6c009b258fd3 to your computer and use it in GitHub Desktop.

Select an option

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…
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