Question: # Badge: Haunted House Explorer # Initialize the total hours spent in the house total _ hours = 0 # Function to explore a room
# Badge: Haunted House Explorer
# Initialize the total hours spent in the house
totalhours
# Function to explore a room
def exploreroomroomname:
spookydescriptions
"Living Room": "You feel a cold breeze and hear faint whispers in the air.",
"Kitchen": "The old dishes rattle as if someone is cooking in the dark.",
"Bedroom": "The creaking sound of footsteps echoes through the room.",
# Display the spooky description for the selected room
printf
You enter the roomnamespookydescriptions.getroomname
# Main program loop
while True:
# Display options to the user
print
Choose an option:"
print Explore the Living Room"
print Explore the Kitchen"
print Explore the Bedroom"
print Leave the Haunted House"
# Get user input
choice inputEnter the number of your choice:
# Logic to earn the badge keeping track of total hours
if choice.isdigit:
choice intchoice
if choice :
totalhours
exploreroomLiving Room", "Kitchen", "Bedroom"choice
elif choice :
printfYou have spent a total of totalhours hours in the haunted house. Farewell!"
break
else:
printInvalid choice. Please enter a number between and
else:
printInvalid input. Please enter a number." explain how the hour tracker works keep the badge name make sure you included this in code and leave a comment explaining the program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
