陽臺上的花怕冷。列表裡是這些天晚上的溫度。寫 cold_nights(temps, limit),返回有幾晚的溫度比 limit 低(正好等於不算)。
cold_nights([3, -1, 5, -4, 0], 0)→2cold_nights([8, 9, 10], 5)→0def cold_nights(temps, limit):
count = 0
for t in temps:
# 在這裡寫:比 limit 低,count 就加 1
pass
return count
寫好了先點「執行」試試示例,沒問題再點「提交」。