Israel.Segundo
BAN USER
def get_hotels(score_list, min_avg_score):
hotel_list = {}
# Create a dictionary where we classify scores by hotel id
for hotel_score in score_list:
hotel_id = hotel_score['hotel_id']
if not hotel_id in hotel_list.keys():
hotel_list[hotel_id] = []
hotel_list[hotel_id].append(int(hotel_score['score']))
# Create a list of hotels that have at least the min_avg_score
hotel_result_list = []
for hotel_id in hotel_list.keys():
score_average = (sum(hotel_list[hotel_id]) / len(hotel_list[hotel_id]))
if score_average >= min_avg_score:
hotel_result_list.append(hotel_id)
return hotel_result_list
scores = [
{'hotel_id': 1001, 'user_id': 501, 'score': 7},
{'hotel_id': 1001, 'user_id': 502, 'score': 7},
{'hotel_id': 1001, 'user_id': 503, 'score': 7},
{'hotel_id': 2001, 'user_id': 504, 'score': 10},
{'hotel_id': 3001, 'user_id': 505, 'score': 5},
{'hotel_id': 2001, 'user_id': 506, 'score': 5}
]
print "get_hotels(scores,5) -> " + str(get_hotels(scores,5))
print "get_hotels(scores,7) -> " + str(get_hotels(scores,7))
RepEdwin Adcox, Dev Lead at Advisory Board Company
Welcome to the best and certified exotic car rental company of USA. Here, at Prestige luxury Rentals, we offer the ...
Repuspoolbuilderus, Site Reliability Engineer at Delve Networks
U.S. Pool Builder is the best licensed inground concrete pool design and swimming pool builders katy TX.Our main ...
RepNY Vape Shop is the most popular Vaporizer Store for new trend vaporizer pen and all related accessories. We are ...
RepBlack magic mantra is simple and easy mantra. Call our specialist today for advice on black magic mantra to kill ...
Open Chat in New Window
- Israel.Segundo July 13, 2016