0
이것은 내 파이썬 코드의 일부입니다. c/l/d가 아닌 다른 문자를 입력 한 후에는 "동물이 있습니까?"라는 질문을해야합니다. 그러나 그것은 작동하지 않습니다. 다른 글자를 입력하면 "한 시간 동안 속도를 낼 수 있습니까?"라고 묻습니다. 한 번만 더 묻고 다음에 "동물이 있습니까?"라고 묻습니다.파이썬 while 루프 오류
다른 문자 코드를 입력 할 때 "나는 동물이 있습니까?"하고 묻습니다.
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 == "c"또는 type == "d"또는 유형 == "l"': – toonarmycaptain