The Boredless Tourist

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

Hello,

I am stuck on the python exercise “The Boredless Tourist”:
The Boredless Tourist

I completed 1 to 28.
Then it say to skip 29 and 30, and I just don’t understand 31, I do not understand what is asked of me to do.
I have this now (up to 28)

destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "Sao Paulo, Brazil", "Cairo, Egypt"]
test_traveler = ["Erin Wilkes", "Shanghai, China", ["historical site", "art"]]
#attractions = []
#for _ in destinations:
#  attractions.append([])
attractions = [ [] for _ in destinations]

#def get_destination_index(destination):
#  for i in range(len(destinations)):
#    if destination == destinations[i]:
#      destination_index = i
#      return destination_index
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

def add_attraction(destination,attraction):
  destination_index = get_destination_index(destination)
  

test_destination_index = get_traveler_location(test_traveler)

print(test_destination_index)

# For testing pursposes
print(get_destination_index("Los Angeles, USA")) # This works fine
print(attractions)

If anyone could make me understand, thanks in advance :slight_smile:

Copying the Task 31 instruction for easy reference:

If the destination does exist, then we already have a list for it in attractions. Use the destination_index to find the appropriate list in attractions and save that list to attractions_for_destination.

A detail that these instructions lack is that this is still going within the definition of add_attraction(). In Task 28, you used the destination passed into add_attraction() to get the index of that destination within the destinations list. Task 31 is then asking you to use the destination_index to get the corresponding sublist from attractions for that destination (remember, the attractions in attractions[0] should correspond with the destination at destinations[0]).

Put another way, you’re getting the list of attractions specific to the destination that was passed in to add_attraction() so that you can append the attraction to it in Task 32.

Hope that clears it up a bit, happy coding!

I have reached line 48, however I have an error on line 43

SyntaxError: Non-ASCII character '\xc3' in file script.py on line 43, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

This is a code block belonging to the list provided by the platform.

add_attraction("São Paulo, Brazil", ["São Paulo Zoo", ["zoo"]])

The answer is that python doesn’t recognize special character symbols and when edited it solved.