Created
March 10, 2015 03:24
-
-
Save rlieberman/c281828a98c2d8f9e63d 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
import random | |
airstrike_list = list() #make an empty list for the words in airstrike | |
all_words = list () #make an empty list called all_words | |
meat = open('meat.txt').read() #load meat into a string | |
for item in meat.split(): #load the words in meat into the list | |
all_words.append(item) | |
for line in open('airstrike.txt'): #for each line in airstrike.txt | |
line = line.strip() #strip the whitespace | |
if len(line) > 0: | |
line_words = line.split() #split the line into words | |
airstrike_list.append(line_words[1:]) #add the words in that line to the list (after the first word, skip the #) | |
for item in airstrike_list: #for every word in the airstrike list | |
all_words.append(item) #add that to the list all_words | |
for i in range(8): #create a loop that runs 8 times | |
num_words = random.randrange(1, 6) #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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment