The Boredless Tourist, "get_attraction_for_traveler"

I got stuck in the last function get_attraction_for_traveler(), when I call this function
I get a valueerror “ValueError: ‘Paris, France’ is not in list”
I cannot find the error,
Does anyone could please help me to debug my error?

destinations = ["Paris,France", "Shanghai, China", "Los Angeles, USA", "São Paulo, Brazil", "Cairo, Egypt"]

test_traveler = ['Erin Wilkes', 'Shanghai, China', ['historical site', 'art']]

attractions = [[] for dest in destinations]


def get_destination_index(destination):

  destination_index = destinations.index(destination)

  return destination_index

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(get_destination_index("Hyderabad, India"))

def add_attraction(destination,attraction):


    destination_index = get_destination_index(destination)

    attractions_for_destination = attractions[destination_index]


  except ValueError:    


def find_attraction(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[0]

    for inter in interests:

      if inter in attraction_tags:


  return attractions_with_interest

def get_attraction_for_traveler(traveler):

  traveler_destination = traveler[1]

  traveler_interests = traveler[2]

  traveler_attractions = find_attraction(traveler_destination, traveler_interests)

  interests_string = "Hi " + traveler[0] + ", we think you'll like these places around " + traveler_destination + ": "

  for i in range(len(traveler_attractions)):

    if traveler_attractions[-1] == traveler_attractions[i]:

      interests_string += "the " + traveler_attractions[i] + "."


        interests_string += "the " + traveler_attractions[i] + ", "

  return interests_string

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"]])


la_arts = find_attraction("Los Angeles, USA",['art'])


smills_france = get_attraction_for_traveler(['Dereck Smill', 'Paris, France', ['monument']])


looking at your destinations:

destinations = ["Paris,France", "Shanghai, China", "Los Angeles, USA", "São Paulo, Brazil", "Cairo, Egypt"]

I don’t see "Paris, France". I see "Paris,France". So the error make sense.

String comparison means every character needs to match, this include white spaces.

1 Like

Thank you, I can’t believe I didn’t see this