Need Help on project (The Boredless Tourist)

Hello :slight_smile:
i am doing the project The Boredless Tourist and i come acrros one problem a tried many differents ways put still didnt find the mistake. If anyone can help me i will be very thankful.
Problem:

Try adding the following attraction = [‘Venice Beach’, [‘beach’]] To the “Los Angeles, USA” destination by calling add_attraction() with the two as arguments.

Everytime i call the function i get this error:

File “script.py”, line 26, in add_attraction
attractions_for_destination = attraction[destination_index].append(attraction)
IndexError: list index out of range

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

# print(get_destination_index('Hyderabad, India'))
# print(get_destination_index('Los Angeles, USA'))

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)

# print(test_destination_index)

attractions = [[] for destination in destinations]
# print(attractions)

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

add_attraction('Los Angeles, USA', ['Venice Beach', ['beach']])
print(attractions)
  attractions_for_destination = attraction[destination_index].append(attraction)`

Should be:

  attractions_for_destination = attractions[destination_index].append(attraction)

Looks like there was a missing S on attractions. So the argument was appending on itself, instead of the attractions list above.

2 Likes

Thank you very much :slight_smile: