Expected indent on def function error

I just wanna say is that i just started in programming so please don’t judge me
but i keep getting an error that says expected an indented block

import sys
import time
from time import sleep

def slowprint(s):
for c in s + ‘\n’:
sys.stdout.write©
sys.stdout.flush()
time.sleep(0.25/10)

LOSS_MESSAGE = “Awwww looks like you died… oh well better luck next time”
WIN_MESSAGE = “Congrats! You GOT OUT!”
EXIT_MESSAGE = “Goodbye!! I hope you play again sometime”

print(“Welcome to Get Out!”)

def Start_game():
option = input(“Enter YES to to play the game and NO to exit”)
option = option.upper()

if option == 'NO':
 print("Game is now exiting")
 return
elif option == 'YES':
 slowprint("The game will now start please wait while the game loads")
 slowprint("=========================================================")
 slowprint("||||||||  ||||||  ||||||   |||||||  ||  ||  ||||||  |||")
 slowprint("||        ||        ||     ||   ||  ||  ||    ||    |||")
 slowprint("|| |||||  ||||      ||     ||   ||  ||  ||    ||    |||")
 slowprint("||    ||  ||        ||     ||   ||  ||  ||    ||       ")
 slowprint("||||||||  ||||||    ||     |||||||  ||||||    ||    |||")
 slowprint("=========================================================")

Start_game()

sleep(2)

def cls():
print("\n" * 100)

def start_room():
start_room_options = [“1”,“2”]
user_choice =""
while user_choice not in start_room_options:
cls()
slowprint(’’'You don’t seem to remember much but you are in an attic and you are tied up…
You search your surroundings and you see a window and a hatch. You realize that the knot isn’t tied tightly…
So you untie yourself and you decide where to go

  1. Exit through the window

  2. Go down the hatch’’’)

    user_choice = input(“Enter the number of your answer:”)
    print ("You have selected " + user_choice)
    sleep(1.5)
    if user_choice == start_room_options[1]:
    hallway_1()
    elif user_choice == start_room_options[0]:
    print(“OUCH!”)
    slowprint(“You fell and landed on the spike of the fence and died”)
    print(LOSS_MESSAGE)
    again = input(“Enter YES to play again and enter NO to exit”)
    again = again.upper
    if again == ‘YES’:
    return start_room

       elif again == 'NO':
         print(EXIT_MESSAGE)
         return
    

def hallway_1():
hallway_1_options = [“1”, “2”]
user_choice =""
cls()
slowprint(“You are in a hallway and there are two doors on your left and on your right”)
print(’’’

  1. Go the door on your left

  2. Go to the door on your right’’’)
    user_choice = input(“Enter the number of your answer:”)
    sleep(1)
    if user_choice == hallway_1_options[0]:
    hallway_2()

    elif user_choice == hallway_1_options[1]:
    downstairs_1()

def hallway_2():
hallway_2_options = [“1”, “2”]
user_choice =""
cls()
slowprint(“You are in another hallway and you see a dark figure infront of you”)
print(’’’

  1. Go back

  2. Approach it’’’)
    user_choice = input(“Enter the number of your answer:”)
    sleep(0.5)
    if user_choice == hallway_2_options[0]:
    return hallway_1

    elif user_choice == hallway_2_options[1]:

def downstairs_1

start_room()

1 Like

Hey, highlight ALL of your code and click the formal button in the toolbar so we can read EXACTLY how it is laid out on your side.
Also something you could do as well (especially since you will probably be making your own stuff) get and IDE (Integrated Development Environment) and download yourslelf the pylint extension. Pylint ‘rolls’ your code for errors, I began using the Visual Code program on my machine because it has alot of abilities and addons that help you (example, it gives snippets so you don’t have to repeatedly type elifs over and over.) on that they have things like Code runner and automatic indenter.

You could also take your code somewhere that has a debugger and debug it to see WHERE the indent error happens.

1 Like

It appears one is starting at the deep end of the pool. If we cannot explain what each piece of code is doing, we should not be using it. In other words, taking a large program and expecting to learn from it is not an appropriate way to learn any language.

Suggest complete the Learn Python track to get immersed in the basics of the language and gradually work your way up to larger projects.

2 Likes