Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "So Paulo, Brazil", "Cairo, Egypt"]
  2. test_traveler = ["Erin Wilkes", "Shanghai, China", ["historical site", "art"]]
  3. def get_destination_index(destination):
  4. destination_index = destinations.index(destination)
  5. return destination_index
  6. def get_traveler_location(traveler):
  7. traveler_destination = traveler[1]
  8. traveler_destination_index=get_destination_index(traveler_destination)
  9. return traveler_destination_index
  10. test_destination_index = get_traveler_location(test_traveler)
  11. attractions = [[] for i in destinations]
  12. attractions_for_destinations = [[] for i in destinations]
  13. def add_attraction(destination, attraction):
  14. try:
  15. destination_index=get_destination_index(destination)
  16. attractions_for_destinations[destination_index].append(destinations[destination_index])
  17. attractions[destination_index].append(attraction)
  18. attractions_for_destinations[destination_index].append(attractions[destination_index])
  19. except ValueError:
  20. print("Error caught!")
  21. return
  22. add_attraction("Los Angeles, USA", ["Venice Beach", ["beach"]])
  23. add_attraction("Paris, France", ["the Louvre", ["art", "museum"]])
  24. add_attraction("Paris, France", ["Arc de Triomphe", ["historical site", "monument"]])
  25. add_attraction("Paris, France", ["Testy boy", ["historical site", "monument"]])
  26. add_attraction("Shanghai, China", ["Yu Garden", ["garden", "historcical site"]])
  27. add_attraction("Shanghai, China", ["Yuz Museum", ["art", "museum"]])
  28. add_attraction("Shanghai, China", ["Oriental Pearl Tower", ["skyscraper", "viewing deck"]])
  29. add_attraction("Los Angeles, USA", ["LACMA", ["art", "museum"]])
  30. add_attraction("So Paulo, Brazil", ["So Paulo Zoo", ["zoo"]])
  31. add_attraction("So Paulo, Brazil", ["Ptio do Colgio", ["historical site"]])
  32. add_attraction("Cairo, Egypt", ["Pyramids of Giza", ["monument", "historical site"]])
  33. add_attraction("Cairo, Egypt", ["Egyptian Museum", ["museum"]])
  34. def find_attractions(destination, interests):
  35. attractions_with_interest = []
  36. possible_attraction = []
  37. attractions_in_city = []
  38. destination_index = get_destination_index(destination)
  39. attractions_in_city = (attractions[destination_index])
  40. for i in range(len(attractions_in_city)):
  41. possible_attraction = attractions_in_city[i]
  42. for interest in interests:
  43. for attractionss in possible_attraction:
  44. for attractionsss in range(len(attractionss)):
  45. if interest == attractionss[attractionsss]:
  46. attractions_with_interest.append(possible_attraction[0])
  47. return attractions_with_interest
  48. la_arts = find_attractions("Los Angeles, USA", ['art'])
  49. def get_attractions_for_traveler(traveler):
  50. traveler_destination = traveler[1]
  51. traveler_interests = traveler[2]
  52. traveler_attractions = find_attractions(traveler_destination, traveler_interests)
  53. interests_string = "Hi %s, we think you'll like these places around %s: " %(traveler[0], traveler_destination)
  54. for i in range(len(traveler_attractions)):
  55. interests_string = interests_string + traveler_attractions[i]
  56. if len(traveler_attractions)-i<=1:
  57. interests_string = interests_string + "."
  58. else:
  59. interests_string = interests_string + ", "
  60. return interests_string
  61.  
  62. Derek_Smill = ['Dereck Smill', 'Paris, France', ['monument']]
  63. print(get_attractions_for_traveler(Derek_Smill))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement