Boredless Tourist

I keep getting an Indentation error on line 19 for try:, I even matched it up with the walkthrough

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
test_destination_index = get_traveler_location(test_traveler)

attractions = [[], [], [], [], []]

*def add_attraction(destination, attraction):*
*  try:*
*    destination_index = get_destination_index(destination)*
*    attractions_for_destination = attractions[destination_index].append(add_attraction)*
*  except ValueError:*
*    return*
      
add_attraction('Los Angeles, USA', ['Venice Beach', ['beach']])
print(attractions)

Hmm. Try copying the code, then resetting the lesson, then pasting the code back into the editor. When I run it off platform, I get the following result:

[[], [], [<function add_attraction at 0x7f940aea4040>], [], []]

Okay so the error is gone now I’m getting what you got

Got it thanks man

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
test_destination_index = get_traveler_location(test_traveler)

attractions = [[], [], [], [], []]

def add_attraction(destination, attraction):
  try:
    destination_index = get_destination_index(destination)
    attractions_for_destination = attractions[destination_index].append(attraction)
  except ValueError:
    return
      
add_attraction('Los Angeles, USA', ['Venice Beach', ['beach']])
print(attractions)```
1 Like