Skip to content

Instantly share code, notes, and snippets.

@billtubbs
Last active Jan 18, 2017
Embed
What would you like to do?
#!/usr/bin/env python
# PRACTICE PYTHON script 'Pick Word'
# http://www.practicepython.org/exercise/2016/09/24/30-pick-word.html
import random
SOWPODS_FILE = "sowpods.txt"
def random_word(filename=SOWPODS_FILE):
"""Returns a random word from a local
copy of the SOWPODS dictionary
Source: http://norvig.com/ngrams/sowpods.txt"""
f = open(filename, 'r')
lines = f.readlines()
f.close()
return random.choice(lines).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment