I need help with the boredless tourist exercise

destinations = [“Paris, France”,“Shanghai, China”,“Los Angeles, USA”,“Sao 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
#get traveler location
def get_traveler_location(traveler):
traveler_destination = 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)
#let’s see what attractions the person wants to see
attractions = [ for destination in destinations]
print(attractions)
def add_attraction(destination,attraction):
destination_index = get_destination_index(destination)
attractions_for_destination = attractions[destination_index]
attractions_for_destination.append(add_attraction[attraction])
return
add_attraction([‘Venice Beach’,[‘beach’]])
print(attractions)
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”, “historical 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”]])
#lets find the best places to go
def find_attractions(destination,interests):
destination_index = get_destination_index()
attractions_in_city = attractions[destination_index]
attractions_with_interest =
for attraction in attractions_in_city:
possible_attraction = attraction
attraction_tags = possible_attraction[1]
for interest in interests:
if interest in attraction_tags:
attractions_with_interest.append(possible_attraction[0])
return attractions_with_interest
la_arts = find_attractions(“Los Angeles, USA”,[‘art’])
print(la_arts)

the output
destinations = [“Paris, France”,“Shanghai, China”,“Los Angeles, USA”,“Sao 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
#get traveler location
def get_traveler_location(traveler):
traveler_destination = 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)
#let’s see what attractions the person wants to see
attractions = [ for destination in destinations]
print(attractions)
def add_attraction(destination,attraction):
destination_index = get_destination_index(destination)
attractions_for_destination = attractions[destination_index]
attractions_for_destination.append(add_attraction[attraction])
return
add_attraction([‘Venice Beach’,[‘beach’]])
print(attractions)
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”, “historical 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”]])
#lets find the best places to go
def find_attractions(destination,interests):
destination_index = get_destination_index()
attractions_in_city = attractions[destination_index]
attractions_with_interest =
for attraction in attractions_in_city:
possible_attraction = attraction
attraction_tags = possible_attraction[1]
for interest in interests:
if interest in attraction_tags:
attractions_with_interest.append(possible_attraction[0])
return attractions_with_interest
la_arts = find_attractions(“Los Angeles, USA”,[‘art’])
print(la_arts)

Hello @samuelgu6291103191, welcome to the forums! Can you be a little more descriptive in what you want help with, please? Is there an error? If so, what is it? Is the output undesirable? If so, how?

1 Like

I mean it errored out.

What’s the error message that you’re getting?

It wouldn’t compile when you put it in the IDE. Just try it out for yourself.

Since the indentation hasn’t been preserved, I can’t paste it into an editor/IDE without it throwing many errors; however, if you post the error you’re getting, I can help you. Alternatively, please follow this guide on formatting code in posts.

1 Like