我如何修复基于文本的冒险游戏中的缩进错误

How do i fix an indention error in my text based adventure game

我正在制作一个基于文本的冒险游戏,但是我尝试了 运行 我程序的一部分,并且在有我无法修复的 astricks 的行中存在缩进错误。有人可以给我一些指示。谢谢!我们将不胜感激所有帮助

这是我的部分代码:

   import random
   import time
   randint = random.randint(1, 9)
   randint2 = random.randint(1, 8)
   randint3 = random.randint(1, 7)
   randint4 = random.randint(1, 3)
   person_name = input('What is your name? ')
   print('your name is: ',person_name)
   print('you have been trapped in a haunted house....You have to hurry and                            escape this house')
   time.sleep(0.9)
   roomchoice_1 = input('You are currently located in the living room.                 Would you like to walk to the Kitchen, bedroom, or the basement?: ')
   time.sleep(1.32)

   if roomchoice_1 == 'Kitchen':
    print('okay you are now in the kitchen, now solve the combination lock.   It will help you get out of here!')
    time.sleep(1.5)
    print('You have three guesses, if you get all three  wrong......well....you,ll die. Good Luck!')
    time.sleep(1.5)
    num1 = int(input('enter your first number, from 1 - 9'))
    print(' the correct number is: ' + randint)
    if num1 == randint:
     print('correct! You may now move on')
    else:
     print('oops, that wasnt the correct number. Try again. You now have 2  tries remaining')
     num2 = int(input('Choose your second number, from 1 - 8'))
     if num2 == randint2:
        print('Congrats you have successfully found the code')
     else:
        print('uhhh....that wasnt the correct number either...try again.')
        num3 = int(input('choose your third and final number between 1 and 7'))
        print('the correct number is', randint3)
        if num3 == randint3:
            print('well done ,success, you have opened the combination lock... You have obtained a key')
            L_1 = input(' Now would you like to travel to the bedroom or basement')
            if L_1 == 'Bedroom':
                            #insert bedroom code
        ***else:***
            print('Oh NO!, you have guessed incorrectly three times....')
            print(pass)# insert in print statement a code photo of a hole
            print(person_name, ' has died')
            print(pass)# insert text image of skull
   if roomchoice_1 == 'bedroom':
    print('You have walked into the bedroom.....')
    time.sleep(1)
    print('LOOK... there are three doors... You have to choose the correct  one...carefull! You only have one chance')
    choice_door = int(input('Choose one of the following doors: Door 1, Door 2, or Door 3'))
    if choice_door = randint4:
     print('Good Job... You have chosen the right door....')
     time.sleep(1)
     print('look behind the door... there is a chest...try open it...')
     open_chest = input('Would you like to open the chest')
     if open_chest == 'yes':
        print('Look... there is another key... this might be the key that opens the from')

因此强烈建议使用 'TAB' 来标识您的代码以避免这些错误,因此如果您的 'if' 语句中有任何内容,它应该使用一个 TAB 等等。始终使用 TAB 来识别。因此,基于此,它就在这里。

import random
import time


randint = random.randint(1, 9)
randint2 = random.randint(1, 8)
randint3 = random.randint(1, 7)
randint4 = random.randint(1, 3)
person_name = input('What is your name? ')
print('your name is: ',person_name)
print('you have been trapped in a haunted house....You have to hurry and                            escape this house')
time.sleep(0.9)
roomchoice_1 = input('You are currently located in the living room.                 Would you like to walk to the Kitchen, bedroom, or the basement?: ')
time.sleep(1.32)

if roomchoice_1 == 'Kitchen':
    print('okay you are now in the kitchen, now solve the combination lock.   It will help you get out of here!')
    time.sleep(1.5)
    print('You have three guesses, if you get all three  wrong......well....you,ll die. Good Luck!')
    time.sleep(1.5)
    num1 = int(input('enter your first number, from 1 - 9'))
    print(' the correct number is: ' + randint)
if num1 == randint:
    print('correct! You may now move on')
else:
    print('oops, that wasnt the correct number. Try again. You now have 2  tries remaining')
    num2 = int(input('Choose your second number, from 1 - 8'))
    if num2 == randint2:
        print('Congrats you have successfully found the code')
    else:
        print('uhhh....that wasnt the correct number either...try again.')
        num3 = int(input('choose your third and final number between 1 and 7'))
        print('the correct number is', randint3)
    if (num3 == randint3):
        print('well done ,success, you have opened the combination lock... You have obtained a key')
        L_1 = input(' Now would you like to travel to the bedroom or basement')
        if (L_1 == 'Bedroom'):
            pass             #insert bedroom code
        else:
            print('Oh NO!, you have guessed incorrectly three times....')
            #print(pass) # insert in print statement a code photo of a hole
            print(person_name, ' has died')
            #print(pass)# insert text image of skull

if roomchoice_1 == 'bedroom':
    print('You have walked into the bedroom.....')
    time.sleep(1)
    print('LOOK... there are three doors... You have to choose the correct  one...carefull! You only have one chance')
    choice_door = int(input('Choose one of the following doors: Door 1, Door 2, or Door 3'))
    if choice_door == randint4:
        print('Good Job... You have chosen the right door....')
        time.sleep(1)
        print('look behind the door... there is a chest...try open it...')
        open_chest = input('Would you like to open the chest')
        if open_chest == 'yes':
            print('Look... there is another key... this might be the key that opens the from')