Skip to content

Instantly share code, notes, and snippets.

@zachwhalen
Last active November 6, 2018 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachwhalen/d5fe3d2fd31570b7c327f4c3842ced34 to your computer and use it in GitHub Desktop.
Save zachwhalen/d5fe3d2fd31570b7c327f4c3842ced34 to your computer and use it in GitHub Desktop.
A generated novel for a rainy day.
# because we always need randomness
import random
# create a variable to store the novel as it's being written
novel = ''
# iteration
for i in range(50000):
# add this word to the "novel" 50,000 times
novel += " DRIP"
# add some variety with randomness
r = random.randint(0,100)
# every now and then (about 3% of the time), add a paragraph break
if (r < 3):
novel += ".\n\n "
# every now and then (about 10% of the time), add end punctuation
elif(r > 90):
novel += random.choice([". ","? ",". ","; "])
# print the novel to a file
with open('my_rainyday.txt', 'w') as f:
f.write(novel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment