for some reason, the call to ‘find_attractions’ inside ‘get_attractions_for_traveler’ is not returning any value, which makes the string return incomplete. I’ve tried everything I can, but this isn’t working. Odd thing is: the function works, but not inside…
The traveler’s interests (whether single interest or multiple interests) are expected to be passed as a list. ["monument"] instead of "monument"
# You wrote:
smills_france = get_attractions_for_traveler(
['Dereck Smill', 'Los Angeles, USA', 'monument'])
# It should be:
smills_france = get_attractions_for_traveler(
['Dereck Smill', 'Los Angeles, USA', ['monument']])
To see what happens when you pass the interests as a string (as opposed to a list), then in the find_attractions function, add a print statement for debugging. It will show you iterating over the characters of a string as opposed to the desired behavior of iterating over the strings in a list.
for interest in interests:
print(interest) # <--- For debugging
if interest in attraction_tag:
attractions_with_interest.append(possible_attraction[0])
You have chosen the traveler’s location to be 'Los Angeles, USA' and his interests as ['monument']. But in the current code, there are no attractions in L.A. with a tag of "monument". The attractions in L.A. have tags of ['beach'] and ['art', 'museum'] .
The following code also needs to be revisited:
for i in traveler_attractions:
if traveler_attractions[-1] == traveler_attractions[i]:
interests_string += "the " + traveler_attractions[i] + "."
else:
interests_string += "the " + traveler_attractions[i] + ", "
In its current form, i doesn’t refer to an index. If you want to use i as an index, consider changing it to: