Kodewick
開始學 →
入門←→0 / 112

走夠步數的天

#022入門for s in steps約 3 分鐘

手環記下了每天走的步數,放在列表 steps 裡。寫 goal_days(steps, goal),返回有幾天走到了 goal 步或更多。列表是空的就返回 0。

示例
goal_days([6500, 4200, 8000], 6000)→2
goal_days([3000, 5000], 6000)→0
main.py
def goal_days(steps, goal):
    count = 0
    for s in steps:
        # 在這裡寫:走夠了 goal 步,count 就加 1
        pass
    return count
Ctrl + Enter 也能執行
結果

寫好了先點「執行」試試示例,沒問題再點「提交」。