Kodewick
开始学 →
基础←→0 / 100

几个冷夜

#053基础列表循环约 3 分钟

阳台上的花怕冷。列表里是这些天晚上的温度。写 cold_nights(temps, limit),返回有几晚的温度比 limit 低(正好等于不算)。

示例
cold_nights([3, -1, 5, -4, 0], 0)→2
cold_nights([8, 9, 10], 5)→0
main.py
def cold_nights(temps, limit):
    count = 0
    for t in temps:
        # 在这里写:比 limit 低,count 就加 1
        pass
    return count
Ctrl + Enter 也能运行
结果

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