Created
April 11, 2015 03:44
-
-
Save james-see/78780bdbbe1404d49927 to your computer and use it in GitHub Desktop.
Randomly select a word from a dictionary word list in dicts.py
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
diction="""List of words here""" |
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
# This script pulls down dictionary into list | |
# Date: 04-10-2015 | |
import console | |
import urllib2 | |
import random | |
from dicts import * | |
def r(x): | |
return random.choice(x) | |
cols=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9] | |
console.set_font('Helvetica Neue', 12) | |
console.set_color(r(cols),r(cols),r(cols)) | |
# LINK TO DICTIONARY FILE | |
# words = urllib2.urlopen('http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt').read() | |
wordlist = diction.split() | |
se = r(wordlist) | |
if se[-1] == 's': | |
se = se[:-1] | |
print se | |
else: | |
print se |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment