Boreless Tourist

Hi,
This is my first time posting, I hope I’m doing this correctly. Thanks for help in advance.
The project link is @ https://www.codecademy.com/paths/computer-science/tracks/cspath-cumulative-tourism/modules/cspath-boredless-tourist/projects/the-boredless-tourist

I have been over my code for Boredless Tourist over and over and I can’t pinpoint where I’m wrong. For Step 48 when I print la_arts I get . I’m hoping someone can see what I don’t:


# Define  Variables

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 i in destinations]

# End Define Variables

# Define Functions

def get_destination_index(destination):
   destination_index = destinations.index(destination)

  return destination_index

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

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

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
    attractions_tags = attractions[1]
    
    for interest in interests:
      if interest in attractions_tags:
        attractions_with_interest.append(possible_attraction)
    return attractions_with_interest



# End Define Functions

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_attractions("Los Angeles, USA", ["art"])
print(la_arts)

If you could please format the code for the forums then it’s a lot easier for other to read (especially when indentation is so important). A link to the lesson/project would also be very helpful. The following FAQ covers formatting and guidance on the best way to set up a post for the forums.

1 Like

Thanks for the reply, I missed the back ticks.

In this function, your return statement is indented inside the first for loop. You want that return to be one indentation back, so it happens after the for loops

1 Like

OK, that was an issue but it didn’t fix the outcome. For some reason in this piece of code:

or interest in interests:
      if interest in attractions_tags:
        attractions_with_interest.append(possible_attraction)
  print(possible_attraction)

even though print(possible_attraction) outputs [‘LACMA’, [‘art’, ‘museum’]] … print(attractions_with_interest) is empty after the append

You have a typo here. You want to use attraction[1]. You are using attractionS[1]

PS: the way I found your mistake is by going line by line and using print() statements to see the flow of data as it went from one place to another. If you do print(attraction_tags) you’ll realize that’s not what you were expecting to get. And upon inspection see the typo. Debugging is critical! Getting better at it is a must :+1:

1 Like

THANK YOU SOOOO MUCH!!! I was going through and doing print statements and I’m embarrassed to say I looked that that line but I guess after looking at it so long it “looked right” so I moved on trying to understand where my mistake was.

Can’t thank you enough!!

1 Like