-
Notifications
You must be signed in to change notification settings - Fork 23
/
halloween.py
42 lines (28 loc) · 972 Bytes
/
halloween.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
34
35
36
37
38
39
40
41
42
# I can't be bothered to think of a Hallowe'en costume so
# can you help me generate one randomly?
nouns = []
adjectives = []
with open('things.txt') as f:
# We don't want those stinky \n newline characters
# so we call strip() before adding it to our nouns list.
for line in f:
nouns.append(line.strip())
with open('descriptors.txt') as f:
for line in f:
adjectives.append(line.strip())
def generate_costume():
# pick something random from the nouns and adjectives list
noun = "lazy"
adj = "person"
return (noun, adj)
while True:
(noun, adjective) = generate_costume()
print "You go dressed as a {} {} to the party."
happy = raw_input("Are you happy with this choice? ")
# Check if the user typed something like 'yes' or 'y' and
# quit the program if they are happy.
if happy == True:
exit()
else:
print "OK, I will choose another costume. Hold on..."
print