In Python Boredless tourist project what ami i doing wrong?

As per my understanding I am doing what was in instructions.Even I changed the code of my get_attractions() functions but it is returning just " " instead of showing actual result.

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):
  return destination_index

def get_traveler_location(traveler):
  return  traveler_destination_index


attractions=[ [] for d in destinations]

def add_attraction(destination,attraction):
  except ValueError:
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", ["São Paulo Zoo", ["zoo"]])
add_attraction("Sao 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"]])    

def find_attractions(destination, interests):
  destination_index = get_destination_index(destination)
  attractions_in_city = attractions[destination_index]
  attractions_with_interest = []
  for attraction in attractions_in_city:
    possible_attraction = attraction
    attraction_tags = attraction[1]
    for interest in interests:
      if interest in attraction_tags:
  return attractions_with_interest

la_arts = find_attractions("Los Angeles, USA", ['arts'])



Have you traced your code? Print statements after each function call will help.
Also, a link to the exercise helps.

def find_attractions(destination, interests):
  destination_index = get_destination_index(destination)
  print("destination_index = ", destination_index) # this is 2
  attractions_in_city = attractions[destination_index] 
  print("attractions_in_city = ", attractions_in_city)   

Start there and see if your code does what you expected.
For list comprehensions, review

1 Like

I am checking it through print calls.
After that if it doesn’t work I will send you link.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.