讀書打卡記下了一週 7 天每天讀了幾分鐘。寫 reading_report(minutes),回傳一個字典:"total" 一共幾分鐘,"best_day" 讀得最多的是第幾天(從 1 數,一樣多取前面的),"good_days" 有幾天讀了 30 分鐘或更多。
reading_report([20, 45, 30, 0, 60, 15, 30])→{'total': 200, 'best_day': 5, 'good_days': 4}reading_report([10, 10, 10, 10, 10, 10, 10])→{'total': 70, 'best_day': 1, 'good_days': 0}def reading_report(minutes):
good_days = 0
for m in minutes:
# 在這裡寫:30 分鐘或更多,good_days 加 1
pass
# 在這裡寫:算出 total 和 best_day
total = 0
best_day = 0
return {"total": total, "best_day": best_day, "good_days": good_days}
寫好了先點「執行」試試示例,沒問題再點「提交」。