Boredless Tourist Help


#1

I have been attempting to complete this project and have gotten stuck on this function. The goal of the function is to append the attractions of interest to the empty list. I keep getting an empty list every time I try to print out the function with parameters entered and can’t figure out what is wrong. I’ve even followed the video 100% before this with no success.

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 = attractions[1]

        for interest in interests:
            if interest in attraction_tags:
                attractions_with_interest.append(possible_attraction)
    return attractions_with_interest

Thanks for your help!


#2

Recall that attraction is a list with two elements. The attraction is the second element, so,

 possible_attraction[1]

and,

attractions_with_interest.append(possible_attraction[0])

#3

I tried playing around with calling specific elements of possible_attraction throughout the function yet it had no effect or gave me an error. :frowning:


#4

This,

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:
        attractions_with_interest.append(possible_attraction[0])
  return attractions_with_interest

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

will output,

['LACMA']

#5

This was my error. I’ve passed over that like 100 times lol.

attraction_tags = attractions[1]

I was adding an “s” to the attraction list.