Last active
January 18, 2017 16:34
-
-
Save billtubbs/e6cdc3e9ec847124323b8ce70d00f7ee to your computer and use it in GitHub Desktop.
This file contains 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
#!/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