-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
91 lines (56 loc) · 3.16 KB
/
script.py
File metadata and controls
91 lines (56 loc) · 3.16 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "São Paulo, Brazil", "Cairo, Egypt"]
test_traveler = ["Erin Wilkes", "Shanghai, China", ["historical site", "art"]]
def get_destination_index(destination):
destination_index = destinations.index(destination)
return destination_index
#print(get_destination_index("Hyderabad, India"))
def get_traveler_location(traveler):
traveler_destination = test_traveler[1]
traveler_destination_index = get_destination_index(traveler_destination)
return traveler_destination_index
test_destination_index = get_traveler_location(test_traveler)
#print(test_destination_index)
attractions = [[] for attrac in destinations]
#print (attractions)
def add_attraction(destination, attraction):
try:
destination_index = get_destination_index(destination)
attractions_for_destination = attractions[destination_index].append(attraction)
except ValueError:
return
add_attraction('Los Angeles, USA',['Venice Beach', ['beach']])
add_attraction("Paris, France", ["the Louvre", ["art", "museum"]])
add_attraction("Paris, France", ["Arc de Triomphe", ["historical site", "monument"]])
add_attraction("Shanghai, China", ["Yu Garden", ["garden", "historcical site"]])
add_attraction("Shanghai, China", ["Yuz Museum", ["art", "museum"]])
add_attraction("Shanghai, China", ["Oriental Pearl Tower", ["skyscraper", "viewing deck"]])
add_attraction("Los Angeles, USA", ["LACMA", ["art", "museum"]])
add_attraction("São Paulo, Brazil", ["São Paulo Zoo", ["zoo"]])
add_attraction("São Paulo, Brazil", ["Pátio do Colégio", ["historical site"]])
add_attraction("Cairo, Egypt", ["Pyramids of Giza", ["monument", "historical site"]])
add_attraction("Cairo, Egypt", ["Egyptian Museum", ["museum"]])
#print(attractions)
def find_attractions(destination, interests):
destination_index = get_destination_index(destination)
attractions_in_city = attractions[destination_index]
attractions_with_interest = []
for possible_attraction in attractions_in_city:
attraction_tags = possible_attraction[1]#isso aqui eu tinha colocado attractions[1] e na real era possible_attraction[1]
for interest in interests:
if interest in attraction_tags: #a esse daqui if interest in, isso achei no forum, pq nunca tinha visto in nessa funcao e posicao
attractions_with_interest.append(possible_attraction[0])
return attractions_with_interest#e aqui nesse return eu ainda não tinha colocado ele nessa direção
#la_arts = find_attractions("Los Angeles, USA", ["art"])
#print(la_arts)
def get_attractions_for_traveler(traveler):
traveler_destination = traveler[1]
traveler_interests = traveler[2]
traveler_attractions = find_attractions(traveler_destination, traveler_interests)
interests_string = "Hi " + traveler[0] + ", we think you'll like these places around " + traveler_destination
for attraction in traveler_attractions:
interests_string += ": the " + attraction
return interests_string
smills_france = get_attractions_for_traveler(['Elizabeth', 'São Paulo, Brazil', ['zoo']])
debs = get_attractions_for_traveler(['Deborah', 'Los Angeles, USA', ['beach']])
print(smills_france)
print(debs)