def temperature(weather):
'''(list of ints) -> list of strs
Modify and return list, replacing each temp in list for weather condition.
Hot being over 25 degrees, and cool being under.
'''
したがって、temperature([24, 29, 11]) を実行すると、['cool', 'hot', 'cool'] が返されます。
これは私が得たものです。ただし、リストを変更するのではなく、新しいリストを作成していると思います。for ループを使用して新しいリストを作成する代わりに、リストを変更するにはどうすればよいですか?
temp =[]
for degrees in weather:
if degrees > 25:
temp = temp + ['hot']
else:
temp = temp + ['cool']
return temp