← Back to all posts
##### Indentation errors?

I have one function in use now(pwdgen(line 107)), the rest are just for complexity. When i run, it gives me indentation errors for if statements, why is this happening and how do i fix it?
the 1 == 1's are filler conditions

hotnewtop
obumneme (2)

how to fix error in coding repl

NimboDemi (0)

#MULTI CHOICE STORY

def frontGarden():
print ('You are in a front garden of somebodys house')
print ('In front of you is an open door.')
print ('Behind you is a road.')
elif choice =='Door1':
Door()

else:
print ('Huh?')
frontGarden()

print ('You are on a road.')
print ('You see a car coming.')
print ('Do you:')
print (' Wait in the road for certain death')
print ('OR')
print ('Rush into the house through an open door.')
choice=input('Wait or Door?')
if choice =='Wait':
Wait()
elif choice =='Door':
Door()

def Door():
print ('You entered the house.')
print ('Ahead of you is a staircase.')
print ('To the left is a door. Be careful. One path leads to certain death, and the other leads to happiness. Just be careful.')
choice=input ('Door2 or Stairs?')
if choice =='Door2':
Door2()
elif choice =='Stairs':
Stairs()

def Door2():
print ('You emerge into infinite happiness and life. You are happy.')
print ('OH NO! THERE IS SOMETHING IN THE ROOM! YOU HAVE TO DO SOMETHING!!!')
choice=input ('Kill it or Check it out')
if choice == 'Kill it':
Sword()
elif choice =='Check it out':
Check()
else:
print ('Huh?')
def Stairs():
print ('You go up the stairs into a burning room. ')
print ('You notice a window, or a fire extinguisher.')
choice=input ('Open the window to let out smoke (Window) or grab the Fire extinguisher?')
if choice =='Window':
print ('You go over to the window, only to find that it is already open! You cannot open it even more!')
Stairs()
elif choice =='Fire extinguisher':

def Sword():
print ('You find a sword under the sofa')
print ('You close your eyes and swing at the thing')
print ('When you open your eyes, it was actually an adorable kitten, and you have killed it!')
print ('Your next door neighbors hear a commotion and call the police. They see the sword and the cat and decide you are unstable. They put you in an asylum for the rest of your life.')
Respawn()

def Doom():
print ('You run into the road and wait. You shut your eyes.')
Wait()

def Check():
print ('You open your eyes to a kitten, and you take it and it is your pet')

def Respawn():
print ('You have died and now you need to respawn')
print ('Continue from checkpoint?')
choice=input ('Yes or No')
if choice =='Yes':
frontGarden()
elif choice =='No':
print ('Ok bye then.')
frontGarden()

NimboDemi (0)

I dont have a clue whats wrong with this. Can someone help?

Ill send full code

Victor_Suarez (23)

@NimboDemi

It's expecting something in that elif

Geocube101 (623)

I ran your code. Try removing a SINGLE space in front of the 'if' command on line 88.

Victor_Suarez (23)

@Geocube101 When I add a space it tells me that the indent does not match outer levels, when I take out that indent, it gives me a "expected indent" error, thanks for the suggestion tho

BTW: By any chance, do you happen to know how to work the built-in debugger?

Geocube101 (623)

@Victor_Suarez I do not, however after some messing around with your code, I believe the problem is that you have if statements with a comment instead of code in the code block. as a result, python thinks that the next line of code should be nested inside the function but it isn't.

Victor_Suarez (23)

@Geocube101 I moved all the comments to outside the function and i tried changing the last two if into elifs and I still got that same error

Geocube101 (623)

@Victor_Suarez There has to be code inside the function. If you remove the comments and don't put in executable code, python still returns indent error (Function block can't be empty). Either temporarily comment out the functions or add some code.