usr bin env python3 import random articles The subjects man cat dog ba

 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
#!/usr/bin/env python3
import random
articles = ['The','a']
subjects = ['man','cat','dog','bastard','python']
verbs = ['kiss','grab','choke']
adverbs = ['furiously','firmly','gently']
try:
numLines = input('How many lines of poetry you want? (<Enter> for default)\n')
numLines = int(numLines)
except ValueError:
print('Not a valid number, using default value\n')
numLines = 5
i = 0
while i < numLines:
if random.randint(0,1) > 0:
poetryLine = [random.choice(articles),random.choice(subjects),random.choice(verbs),random.choice(adverbs)]
else:
poetryLine = [random.choice(articles),random.choice(subjects),random.choice(verbs)]
spacedPoetryLine = ''
for line in poetryLine:
spacedPoetryLine += line + " "
print(spacedPoetryLine)
i += 1