手環記下了每天走的步數,放在列表 steps 裡。寫 goal_days(steps, goal),返回有幾天走到了 goal 步或更多。列表是空的就返回 0。
goal_days([6500, 4200, 8000], 6000)→2goal_days([3000, 5000], 6000)→0def goal_days(steps, goal):
count = 0
for s in steps:
# 在這裡寫:走夠了 goal 步,count 就加 1
pass
return count
寫好了先點「執行」試試示例,沒問題再點「提交」。