Skip to content

Instantly share code, notes, and snippets.

@rlieberman
Created March 10, 2015 03:23
Show Gist options
  • Save rlieberman/97856d7edbd1008f76a4 to your computer and use it in GitHub Desktop.
Save rlieberman/97856d7edbd1008f76a4 to your computer and use it in GitHub Desktop.
import random
all_words = list () #make an empty list called all_words
meat = open('meat.txt').read() #load meat and air strike into strings
airstrike = open('airstrike.txt').read()
for item in meat.split(): #load meat into the list
all_words.append(item)
for item in airstrike.split(): #load airstrike into the list
all_words.append(item)
# print all_words
for i in range(5): #print 5 stanzas
for i in range(8): #create a poem with 8 lines (loop that runs 8 times) -
num_words = random.randrange(1, 7) #pick a random number of words per line between 1 and 6
new_line = random.sample(all_words, num_words) #pick that number of words word from the master list all_words
print " ".join(new_line)
print "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment