The Boredless Tourist

I need help with this problem in The Boredless Tourist Project
link = https://www.codecademy.com/paths/computer-science/tracks/cspath-cumulative-tourism/modules/cspath-boredless-tourist/projects/the-boredless-tourist

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

def get_traveler_location(traveler):
  traveler_destination = traveler[1]
  traveler_destination_index = get_destination_index(traveler_destination)
  return traveler_destination_index

attractions = []
for destination in destinations:
  attractions.append([])  

def add_attraction(destination, attraction):
  try:
    destination_index = get_destination_index(destination)
    attractions_for_destination = attractions[destination_index].append(attraction)
  except SyntaxError:
    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"]])

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 interests in attraction_tags:
        attractions_with_interest.append(possible_attraction)
        
la_arts = find_attractions("Los Angeles, USA", ['art'])
print(la_arts)

when i type python3 script.py instead giving [‘LACMA’, [‘art’, ‘museum’]] it gives

Did you return anything from find_attractions so it could be printed?

1 Like

i did it and the result is = <function find_attractions at 0x7f7a14ca49d8

You might add some print statements to see what’s being returned for your different assignments:

def find_attractions(destination, interests):
  destination_index = get_destination_index(destination)
#  print(f"destination_index = {destination_index}")
  attractions_in_city = attractions[destination_index]
#  print(f"attractions_in_city = {attractions_in_city}")
  attractions_with_interest = []
# etc.
1 Like

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