2つの入力を取り、テキストを出力する単純なpython関数を実行しました。
ここにあります、
def weather():
israining_str=input("Is it raining (1 or 0) ? ")
israining = bool(israining_str)
temp_str=input("What is the temp ? ")
temp = float(temp_str)
if israining==True and temp<18:
return "Umbrella & Sweater"
elif israining==True and temp>=18:
return "Umbrella"
elif israining==False and temp<18:
return "Sweater"
else:
return "Cap"
テストデータ -
>>>
Is it raining ? 0
What is the temp ? 43
Umbrella
>>> ================================ RESTART ================================
>>>
Is it raining ? 1
What is the temp ? 43
Umbrella
>>>
raining が false の場合、シュラウドはSweater
またはを与えCap
ます。しかし、私のコードは trueisraining_str == 0
またはisraining_str == 1
私はどこで間違っていますか?