Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "So 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
- 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)
- attractions = [[] for i in destinations]
- attractions_for_destinations = [[] for i in destinations]
- def add_attraction(destination, attraction):
- try:
- destination_index=get_destination_index(destination)
- attractions_for_destinations[destination_index].append(destinations[destination_index])
- attractions[destination_index].append(attraction)
- attractions_for_destinations[destination_index].append(attractions[destination_index])
- except ValueError:
- print("Error caught!")
- return
- add_attraction("Los Angeles, USA", ["Venice Beach", ["beach"]])
- add_attraction("Paris, France", ["the Louvre", ["art", "museum"]])
- add_attraction("Paris, France", ["Arc de Triomphe", ["historical site", "monument"]])
- add_attraction("Paris, France", ["Testy boy", ["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("So Paulo, Brazil", ["So Paulo Zoo", ["zoo"]])
- add_attraction("So Paulo, Brazil", ["Ptio do Colgio", ["historical site"]])
- add_attraction("Cairo, Egypt", ["Pyramids of Giza", ["monument", "historical site"]])
- add_attraction("Cairo, Egypt", ["Egyptian Museum", ["museum"]])
- def find_attractions(destination, interests):
- attractions_with_interest = []
- possible_attraction = []
- attractions_in_city = []
- destination_index = get_destination_index(destination)
- attractions_in_city = (attractions[destination_index])
- for i in range(len(attractions_in_city)):
- possible_attraction = attractions_in_city[i]
- for interest in interests:
- for attractionss in possible_attraction:
- for attractionsss in range(len(attractionss)):
- if interest == attractionss[attractionsss]:
- attractions_with_interest.append(possible_attraction[0])
- return attractions_with_interest
- la_arts = find_attractions("Los Angeles, USA", ['art'])
- 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 %s, we think you'll like these places around %s: " %(traveler[0], traveler_destination)
- for i in range(len(traveler_attractions)):
- interests_string = interests_string + traveler_attractions[i]
- if len(traveler_attractions)-i<=1:
- interests_string = interests_string + "."
- else:
- interests_string = interests_string + ", "
- return interests_string
- Derek_Smill = ['Dereck Smill', 'Paris, France', ['monument']]
- print(get_attractions_for_traveler(Derek_Smill))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement