else 추가하기
스크립트에서 room에 대한 if 구문이 else 문으로 확장되어, 조건 room == "kit"가 False로 평가되면 "looking around elsewhere."가 출력됩니다.
area에 대한 if 구문에도 같은 방식으로 기능을 추가할 수 있을까요?
이 연습은 강의의 일부입니다
중급 Python
연습 안내
area > 15가 False로 평가될 때 "pretty small."이 출력되도록, 두 번째 제어 구조에 else문을 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Define variables
room = "kit"
area = 14.0
# if-else construct for room
if room == "kit" :
print("looking around in the kitchen.")
else :
print("looking around elsewhere.")
# if-else construct for area
if area > 15 :
print("big place!")