Add else
In the script, the if
construct for room
has been extended with an else
statement so that "looking around elsewhere." is printed if the condition room == "kit"
evaluates to False
.
Can you do a similar thing to add more functionality to the if
construct for area
?
This exercise is part of the course
Intermediate Python
Exercise instructions
Add an else
statement to the second control structure so that "pretty small." is printed out if area > 15
evaluates to False
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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!")