I just wanted to share my final return string for loop . I think it’s a lot easier than the video solution. For brevity sakes, I will just post the last function where you can find the logic for when the program should add either a ‘,’ or ‘and’
Make sure you duplicate a few attractions with the same tags so you can test it yourself in your code.
def get_attractions_for_traveler(traveler): traveler_destination = traveler traveler_interest = traveler traveler_attractions = find_attractions(traveler_destination,traveler_interest) interests_string = 'Hi ' interests_string += traveler interests_string += ", we think you'll like these places around " + traveler_destination + ': ' for attraction in traveler_attractions: interests_string += attraction if attraction == traveler_attractions[-2]: interests_string += ' and ' elif attraction != traveler_attractions[-1]: interests_string += ', ' interests_string += '.' return interests_string