Skip to content

Instantly share code, notes, and snippets.

@michaeluzzi
Created February 27, 2013 18:07
Show Gist options
  • Save michaeluzzi/5050079 to your computer and use it in GitHub Desktop.
Save michaeluzzi/5050079 to your computer and use it in GitHub Desktop.
Outputs random poems using the tweets of Kanye and Kim and input.
import sys
import random
all_words = list()
for line in open('kim-tweets.txt'):
line = line.strip()
line = line.lower()
line = line.replace(".", "")
line = line.replace(",", "")
line_words = line.split(" ")
for word in line_words:
all_words.append(word)
for line in open('kanye-tweets.txt'):
line = line.strip()
line = line.lower()
line = line.replace(".", "")
line = line.replace(",", "")
line_words = line.split(" ")
for word in line_words:
all_words.append(word)
random.shuffle(all_words)
for i in range(random.randint(6, 20)):
line = ""
for j in range(random.randint(0, 10)):
line += random.choice(all_words)
line += " "
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment