Why I can not get the result "Arc de Triomphe" in The Boredless Tourist exercise?

I made all the exercise watching the YouTube video reference. The video is old and it’s very difficult to follow. Here is my code. Could someone tell me what could be failing?
Thanks a lot.

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):
destination_index = get_destination_index(destination)
attractions[destination_index].append(attraction)
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”, “historical 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 interest in attraction_tags:
    attractions_with_interest.append(possible_attraction[0])

return attractions_with_interest

def get_attractions_for_traveler(traveler):
traveler_destination = traveler[1]
traveler_interest = traveler[2]
traveler_attractions = find_attractions(traveler_destination, traveler_interest)

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

for i in range(len(traveler_attractions)):
return interests_string

smills_france = get_attractions_for_traveler([‘Dereck Smill’, ‘Paris, France’, [‘monument’]])

print(smills_france)

Please format your code so people can read it. Use the </> button above, or,

2 Likes

Sorry, is it ok like this? I am new…

“”"

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):
destination_index = get_destination_index(destination)
attractions[destination_index].append(attraction)
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”, “historical 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 interest in attraction_tags:
    attractions_with_interest.append(possible_attraction[0])

return attractions_with_interest

def get_attractions_for_traveler(traveler):
traveler_destination = traveler[1]
traveler_interest = traveler[2]
traveler_attractions = find_attractions(traveler_destination, traveler_interest)

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

for i in range(len(traveler_attractions)):
return interests_string

smills_france = get_attractions_for_traveler([‘Dereck Smill’, ‘Paris, France’, [‘monument’]])

print(smills_france)

“”"

Nope, those are quotation marks. The post I linked to explains it exactly.
Another way:

Or use the gear icon and select “pre-formatted text”.

1 Like

Thanks you very much.
Sorry but my first language in spanish (problems with some words/symbols/commands) and I’m new into coding.
I hope it works this time.
Thanks again.

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):
  destination_index = get_destination_index(destination)
  attractions[destination_index].append(attraction)
  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", "historical 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 interest in attraction_tags:
        attractions_with_interest.append(possible_attraction[0])

  return attractions_with_interest

def get_attractions_for_traveler(traveler):
  traveler_destination = traveler[1]
  traveler_interest = traveler[2]
  traveler_attractions = find_attractions(traveler_destination, traveler_interest)

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

  for i in range(len(traveler_attractions)):
    return interests_string
  
smills_france = get_attractions_for_traveler(['Dereck Smill', 'Paris, France', ['monument']])

print(smills_france)
1 Like

Did you compare your code to what’s in the project walkthrough video? Is the indentation correct in your functions?

So, as a test w/ calling two functions:

smills_france = get_attractions_for_travelers(['Dereck Smill', 'Paris, France', ['monument']])
smills_france2 = find_attractions("Paris, France", ['monument'])

print(smills_france)
print(smills_france2)

>>Hi Dereck Smill, we think you'll like these places around Paris, France: 
>>['Arc de Triomphe']

We can see that the find_attractions function works, b/c it returns a monument for the city. The issue seems to be w/ the get_attractions_for_travelers function logic.

I checked and rechecked with chat GPT and VSCode. I got one good result but I did not found where the error was. The video is older than the exercise and the explanation is not clear to me. The code in the YouTube video is different because it included some more lines that I understood where taken out after it was recorded.
I’m working with your input but if I use the smills_france2 and print(smills_france2) I just got [‘Arc de Triomphe’] and not the complete phrase.

Comment out pieces of your code and use print() to deduce where the error is.
That’s what I was trying to do w/ smills_france2 = find_attractions("Paris, France", ['monument'])

I wouldn’t use CGPT for anything b/c of reliability issues.