Python The Bordless Tourist Project

This is my code for the Bordless Tourist project. I keep getting the following errors when I run it:

Traceback (most recent call last):
** File “script.py”, line 73, in **
** smills_france = get_attractions_for_traveler([‘Dereck Smill’, ‘Paris, France’, [‘monument’]])**
** File “script.py”, line 68, in get_attractions_for_traveler**
** interests_string += "the " + traveler_attractions[i] + “.”**
TypeError: can only concatenate tuple (not “str”) to tuple

Im not sure why Im getting these errors. Can someone help me pinpoint where I’ve gone wrong here?

destinations = [‘Paris, France’, ‘Shanghai, China’, ‘Los Angeles, USA’, ‘Sao 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”))

def get_traveler_location(traveler):
traveler_destination = test_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 place in destinations]
#print(attractions)

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

add_attraction(‘Los Angeles, USA’,[‘Venice Beach’, [‘beach’]])

#print(attractions)

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”, “historcical 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(“Sao Paulo, Brazil”, [“Sao Paulo Zoo”, [“zoo”]])
add_attraction(“Sao 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_interests =
for attraction in attractions_in_city:
possible_attraction = attraction
attraction_tags = attraction[1]
for interest in interests:
if interest in attraction_tags:
attractions_with_interests.append(possible_attraction[0])

return attractions_with_interests

la_arts = find_attractions(“Los Angeles, USA”, [‘art’])
#print(la_arts)

def get_attractions_for_traveler(traveler):

traveler_destination = traveler[1]
traveler_interests = traveler[2]

traveler_attractions = find_attractions(traveler_destination, traveler_interests)

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

for i in range(len(traveler_attractions)):
if traveler_attractions[-1] == traveler_attractions[i]:
interests_string += "the " + traveler_attractions[i] + “.”
else:
interests_string += "the " + traveler_attractions[i] + ", "
return interests_string

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

print(smills_france)

Hi there!

Sorry to hear you’re having trouble. In order to help fellow forum members read your code more easily and answer your question, would you mind formatting it as described in this post?

Here’s a little more information about how to format your posts so they’re easier for others to read and solve.

3 Likes