陽臺上的植物記在一個字典裡:{植物: 幾天沒澆水}。寫 thirsty_plants(days),返回 3 天或更久沒澆水的植物,按字典裡的順序排。都不用澆就返回 []。
thirsty_plants({"fern": 4, "cactus": 10, "mint": 1})→['fern', 'cactus']thirsty_plants({})→[]def thirsty_plants(days):
thirsty = []
# 在這裡寫:用 items() 走一遍,天數夠 3 就把植物放進 thirsty
return thirsty
寫好了先點「執行」試試示例,沒問題再點「提交」。