talison (owner)

Revisions

  • 063c3c Sun May 31 04:54:06 -0700 2009
gist: 120863 Download_button fork
public
Public Clone URL: git://gist.github.com/120863.git
Embed All Files: show embed
awful_poetry.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
 
import sys
import random
 
articles = ["the", "his", "her", "somebody's", "nobody's", "a"]
subjects = ["cat", "hat", "flamingo", "bear", "turd", "belt"]
verbs = ["cried", "laughed", "ran", "melted", "jumped", "ate"]
adverbs = ["loudly", "sadly", "quietly", "mightily", "haughtily", "badly"]
structures = [(articles, subjects, verbs, adverbs), (articles, subjects, verbs)]
 
lines = 5
 
while True:
    try:
        line = input("Enter a number between 1 and 10: ")
        number = int(line)
 
        if 1 <= number <= 10:
            lines = number
 
        break
    except ValueError as err:
        print(err)
        continue
 
while lines:
    poem = ""
    for content in structures[random.randint(0,1)]:
        poem += random.choice(content) + " "
    print(poem)
    lines-=1