解析预期的缩进块时意外的eof

时间:2013-10-12 08:26:38

标签: python parsing indentation

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

1 个答案:

答案 0 :(得分:1)

问题在于:

if search3 == "1":    

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