分析预期的缩进b时出现意外的eof

2024-04-20 13:22:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我对python很陌生,但我正在编写一个简单的游戏。这只是其中的一小部分,但我总是在一行上得到“预期的缩进块”,所以我在分析时得到了意外的eof。不管怎样,这是密码,谢谢你。在

我也知道有很多更简单的方法来编写代码。在

search = input("press 1 to search kitchen, 2 for lounge or 3 for beroom")
if search == "1":
    print("In the kitchen you can see some cupboards and an oven")
    k = input("Press 1 to search cupboards and 2 to search cooker or 3 to return to the front of the house")
    if k == "1":
        print("You find nothing")
        k2 = input("Press 1 to search cooker or 2 to return to the front of the house")
        if k2 == "1":
            print("You find $100")
            print("You return to the front of the house")
            search2 = input("Press 1 to search bedroom or 2 to search lounge")
            if search2 == "1":
                print("In the bedroom you see a man lying on the bed covered on blood")
                check = input("Press 1 to check the body or 2 to return to the front of the house")
                if check == "1":
                    print("You see that the man is alive!")
                    dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
                    if dead == "1":
                        print("You slit the mans throat")
                        print("You then notice a note lying on the man.")
                        print("Its covered in blood but you can make out a few letters.")
                        print("It reads: ssword s 2342")
                        print("You return to the front of the house")
                        #KITCHEN THEN BEDROOM THEN LOUNGE.
                        search4 = input("Press 1 to search lounge or 2 to leave the house")
                        if search4 == "1":
                            print("In the louge you see a TV, a REMOTE CONTROL, a LAPTOP and a BOX")
                            steal = input("Which one will you take? (1 only) *case sensitive* ")
                            if steal == "TV":
                                print("Its too big to carry!")
                                print("you return to the front of the house")
                                leave = input("Press 1 to leave house")
                            elif steal == "REMOTE CONTROL":
                                print("You take the remote control")
                                print("You return to the front of the house")
                                leave = input("Press 1 to leave house")
                            elif steal == "LAPTOP":
                                print("You take the laptop")
                                print("You return to the front of the house")
                                leave = input("Press 1 to leave house")
                            elif steal == "BOX":
                                print("You take the box and open it")
                                print("It has Diamonds inside!")
                                print("You return to the front of the house")
                                leave = input("Press 1 to leave house")


        elif k2 == "2":
            search2 = input("Press 1 to search bedroom or 2 to search lounge")
            if search2 == "1":
                print("In the bedroom you see a man lying on the bed covered on blood")
                check = input("Press 1 to check the body or 2 to return to the front of the house")
                if check == "1":
                    print("You see that the man is alive!")
                    dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
                    if dead == "1":
                        print("You slit the mans throat")
                        print("You then notice a note lying on the man.")
                        print("Its covered in blood but you can make out a few letters.")
                        print("It reads: ssword s 2342")
                        print("You return to the front of the house")
        elif dead =="2":
            print("You return to the front of the house")
    elif check == "2":
        print("Press 1 to search kitchen or 2 to search lounge")

    elif k == "2":
        print("You find £100")
        k3 = input("Press 1 to search cupboards or 2 to return to the front of the house")
        if k3 == "1":
            print("You find nothing")
            print("You return to the front of the house")
            search2 = input("Press 1 to search bedroom or 2 to search lounge")
            if search2 == "1":
                print("In the bedroom you see a man lying on the bed covered on blood")
                check = input("Press 1 to check the body or 2 to return to the front of the house")
                if check == "1":
                    print("You see that the man is alive!")
                    dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
                    if dead == "1":
                        print("You slit the mans throat")
                        print("You then notice a note lying on the man.")
                        print("Its covered in blood but you can make out a few letters.")
                        print("It reads: ssword s 2342")
                        print("You return to the front of the house")


    if k == "3":
        search2 = input("Press 1 to search bedroom or 2 to search lounge")

elif search == "3":
    print("In the bedroom you see a man lying on the bed covered on blood")
    check = input("Press 1 to check the body or 2 to return to the front of the house")
    if check == "1":
        print("You see that the man is alive!")
        dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
        if dead == "1":
            print("You slit the mans throat")
            print("You then notice a note lying on the man.")
            print("Its covered in blood but you can make out a few letters.")
            print("It reads: ssword s 2342")
            print("You return to the front of the house")
        elif dead =="2":
            print("You return to the front of the house")
    elif check == "2":
        print("Press 1 to search kitchen or 2 to search lounge")

elif search == "2":
    print("In the lounge you see a TV, a REMOTE CONTROL, a LAPTOP and a BOX")
    steal = input("Which one will you take? (1 only) *case sensitive* ")
    if steal == "TV":
        print("Its too big to carry!")
        print("you return to the front of the house")
        search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
        if search3 == "1":    
    elif steal == "REMOTE CONTROL":
        print("You take the remote control")
        print("You return to the front of the house")
        search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
    elif steal == "LAPTOP":
        print("You take the laptop")
        print("You return to the front of the house")
        search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
    elif steal == "BOX":
        print("You take the box and open it")
        print("It has Diamonds inside!")
        print("You return to the front of the house")
        search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")

Tags: orofthetoyouinputsearchreturn