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
total_hours =0
# Function to explore a room
def explore_room(room_name):
spooky_descriptions ={
"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
print(f"
You enter the {room_name}.{spooky_descriptions.get(room_name)}")
# Main program loop
while True:
# Display options to the user
print("
Choose an option:")
print("1. Explore the Living Room")
print("2. Explore the Kitchen")
print("3. Explore the Bedroom")
print("4. Leave the Haunted House")
# Get user input
choice = input("Enter the number of your choice: ")
# Logic to earn the badge (keeping track of total hours)
if choice.isdigit():
choice = int(choice)
if 1<= choice <=3:
total_hours +=1
explore_room(["Living Room", "Kitchen", "Bedroom"][choice -1])
elif choice ==4:
print(f"You have spent a total of {total_hours} hours in the haunted house. Farewell!")
break
else:
print("Invalid choice. Please enter a number between 1 and 4.")
else:
print("Invalid 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!