Because chapter 9 of Invent Your Own Computer Games with Python is rather long, I thought we’d break in the middle and do a little messing with lists and string manipulation. Our word list is courtesy of randomlists.com.
Here’s a little example of the program. The kids can borrow what they see fit and come up with creative ways to change how it works.
For a challenge, make sure no word appears twice,
If you’ve stumbled on this randomly, pop it in your favorite Python 3 editor and have fun.
words = "abounding death picayune shut field children heat dime phobic scold bomb wanting brave slippery learned alike cute blind inquisitive chemical trouble moor blue-eyed tow whispering silky birds show selection astonishing nest harass interesting rotten trip grandmother bruise scare lucky broken lumpy iron trite cover brake care pickle branch helpful rule story badge march nice defective beginner spotty mitten bead torpid irritating crime instruct bore stove deadpan warlike spooky icky blade violent pink tangible stimulating orange precious alert tin mailbox float finger jail snore fresh brush tranquil jar explain desire basket activity fireman peck angle powder lamentable snake second-hand squeamish pumped exclusive overflow enter planes scissors license vanish messy shame sheep army crack vagabond island sticks judicious worried puzzling jazzy breath dog suspend sister plants spiky many horn ill comb obnoxious part trick nose grubby far beds spiders curly name grieving vulgar shave capricious tightfisted calculator top judge macho feeling dry mine red wrench scratch step thaw sleepy sip ambiguous dirty relation memory sweater mark ants versed awful nauseating rainy invention drop callous guarded sense uninterested knot sleet porter plot cover erratic punch moon longing influence unarmed hollow whip superb competition sassy obsolete notice riddle pat multiply icy control tidy".split()
num = random.randint(0, len(words)-1)
for i in range(1, 40):
word = getWord()
if i == 1:
per = random.randint(0,6)
if per == 4:
print('.\n' + word.capitalize(), end='')
print(' ' + word, end='')