Kodewick
开始学 →
入门←→0 / 100

走够步数的天

#022入门循环列表约 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 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。