我刚开始学习Python。我试图做一个例子,我真的不明白为什么这段代码没有回复任何答案:
function getMostPopularDestinations()
{
$this->db->query("SET @curRank := 0");
$query = $this->db->query("SELECT vDestination, COUNT(*) AS count, @curRank := @curRank + 1 AS rank FROM tbl_user_trip GROUP BY vDestination ORDER BY vDestination");
return $query->result_array();
}
答案 0 :(得分:0)
存在缩进问题。
您的代码将是..
def scores_to_rating(score1,score2,score3,score4,score5):
score1 = convert_to_numeric(score1)
score2 = convert_to_numeric(score2)
score3 = convert_to_numeric(score3)
score4 = convert_to_numeric(score4)
score5 = convert_to_numeric(score5)
min_score = min(score1, score2, score3, score4, score5)
max_score = max(score1, score2, score3, score4, score5)
sum_of_all_five_scores = score1 + score2 + score3 + score4 + score5
sum_of_three_middle_scores = sum_of_all_five_scores - min_score - max_score
average_score = sum_of_three_middle_scores/3
rating = average_score
return rating
print(scores_to_rating(10,20,30,40,50))