이 코드가 실행되지 않는 이유를 이해할 수없는 것 같습니다. 저는 Python과 프로그래밍을 처음 접했습니다. 반환되는 오류는 잘못된 구문 중 하나이므로 도움을 주시면 감사하겠습니다.
내 코드는 다음과 같습니다.
heightDescription = ["short", "average", "tall", "very tall"]
height = 0
if int(height) <= 188:
print(heightDescription[-1])
if int(height) in range(176, 187)
print(heightDescription[2])
if int(height) in range(161, 175)
print(heightDescription[1])
if int(height) in range(1, 174)
print(heightDescription[0])
@Unisigned Arduino의 답변 외에도 프로그램을 수정했습니다. 범위가 겹치므로 때때로 두 가지 설명이 표시됩니다.
그래서 범위를 수정했고 여기에 전체 코드가 있습니다.
heightDescription = ["short", "average", "tall", "very tall"]
height = 1000
if int(height) <= 188:
print(heightDescription[0])
if int(height) in range(188, 198):
print(heightDescription[1])
if int(height) in range(198, 208):
print(heightDescription[2])
if int(height) in range(208, 228):
print(heightDescription[3])
else:
print(heightDescription[3])
도움이 되었기를 바랍니다!
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다