Skip to content

Instantly share code, notes, and snippets.

@james-see
Created April 11, 2015 03:44
Show Gist options
  • Save james-see/78780bdbbe1404d49927 to your computer and use it in GitHub Desktop.
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
diction="""List of words here"""
# 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