0
これは私のpythonコードの一部です。私はc/l/dではない別の手紙を入力した後、それは "動物はありますか?"と尋ねなければなりません。しかし、それは動作しません。私は別の手紙を入力した後、それは "1時間のaveregeの速度ですか?"ただもう一度これを尋ねると、「動物はいますか?」と私に尋ねる。python whileループエラー
私は別の文字コードを入力するときに私に尋ねます "動物はありますか?"
あなたはinput
の順序を変更する必要が
type=input("enter the type of animal(cheetah:c,lion:l,deer:d):")
speed=float(input("average speed for a hour(km):")
while answer=="Y" or answer=="y":
while type=="c" or type=="d" or type=="l":
if type=="c":
ceetah_count+=1
total_c_speed+=speed
elif type=="d":
deer_count+=1
total_d_speed+=speed
else:
lion_count+=1
total_l_speed+=speed
animal_count+=1
total_speed+=speed
type=input("enter the type of animal(cheetah:c,lion:l,deer:d):")
speed=float(input("average speed for a hour(km):)
answer=input("are there any animals?(yes:y/no:n):)`
を**。 [mcve]を提供してください。 –
字下げがうまくいけば、あなたのコードを見てください –
「答え== "Y"」または答え== "y" 'の後にコロンが必要です:and type while ==" c "またはタイプ== "d"またはタイプ== "l" ': – toonarmycaptain