Problem with the first project (tourist recommendation engine)

Problem is output (print(smells_France)) doesn’t contain city and country names as I would like to, could you help me please ?

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

print(get_destination_index(“Paris, France”))

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)

attractions = [ for attraction in destinations]

def add_attraction(destination, attraction):
destination_index = get_destination_index(destination)
attractions_for_destination = attractions[destination_index].append(attraction)
except SyntaxError:

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(“Sao Paulo, Brazil”, [“Sao Paulo Zoo”, [“zoo”]])
add_attraction(“Sao Paulo, Brazil”, [“Patio do Colegio”, [“historical site”]])
add_attraction(“Cairo, Egypt”, [“Pyramids of Giza”, [“monument”, “historical site”]])
add_attraction(“Cairo, Egypt”, [“Egyptian Museum”, [“museum”]])


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]
for interest in interests:
if interest in attraction_tags:
return attractions_with_interest

la_arts = find_attractions(“Los Angeles, USA”, [“art”])

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 "
for attraction in traveler_attractions:
interests_string += attraction
return interests_string

smills_france = get_attractions_for_traveler([‘Dereck Smill’, ‘Paris, France’, [‘monument’]])


1 Like


Thanks for sharing your code! For readability, please format your coded text by highlighting and pressing the </> button. With python its pretty important.

I would trace your code down the entire smills_france tree (get_attactions_for_traveler) etc. and make sure all those functions and links are working well. You might need to use a few formatted strings to figure it out but if you’re writing this much you’ll be able to isolate it.

I’d also say watch out for the try/except technique here because if I recall for this exercise to work correctly it’s not really necessary. If you still want to use it, you would want to figure out if there’s any information it’s dropping (and make sure it doesn’t).

Thank you for you help :slight_smile:

1 Like