Skip to content

Instantly share code, notes, and snippets.

@billtubbs
Last active January 18, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billtubbs/e6cdc3e9ec847124323b8ce70d00f7ee to your computer and use it in GitHub Desktop.
Save billtubbs/e6cdc3e9ec847124323b8ce70d00f7ee to your computer and use it in GitHub Desktop.
#!/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