-1

我对 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")
4

1 回答 1

1

问题就出在这条线上:

if search3 == "1":    

您有一个 if 语句,后面没有任何内容。

于 2013-10-12T08:29:11.437 回答