forked from jennielees/oh-no-broken-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvacation.py
More file actions
70 lines (49 loc) · 1.59 KB
/
vacation.py
File metadata and controls
70 lines (49 loc) · 1.59 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# This file has a few mistakes and some things I forgot to put in.
# When I run it I don't get anything... can you fix it so I
# get asked for my vacation spot, and get a recommendation?
# Hint:
# Start at the bottom and work upwards.
import site
vacation_spots = {
'snow': 'Tahoe',
'wind': 'Hawaii',
'rain': 'New York',
'sun': 'Mexico'
}
seasons = ['spring', 'summer', 'fall', 'winter']
weather_patterns = {
'spring': 'rain',
'summer': 'sun',
'fall': 'wind',
'winter': 'snow'
}
activities = {
'rain': 'visiting museums',
'wind': 'kiteboarding',
'sun': 'sunbathing',
'snow': 'skiing'
}
def best_vacation_spot(weather_type):
return vacation_spots[weather_type]
def vacation_activity(weather_type):
# Look up the vacation activity from activities
# and return just the activity itself
return activities[weather_type]
def get_my_vacation():
season = raw_input("What season do you want to travel? ")
# check if season is in the seasons list
if season not in seasons:
print "Sorry, that isn't a season. I can't help you."
exit()
# look up the weather type for that season
weather = weather_patterns[season]
# get the best vacation spot for that type
vacation_spot = best_vacation_spot(weather)
# get the best vacation activity for that type
activity = vacation_activity(weather)
print "You should travel to {}, where you can spend your time {}!".format(vacation_spot, activity)
def main():
print "Welcome to the Vacation-o-Matic!"
get_my_vacation()
if __name__=="__main__":
main()