首页 > 解决方案 > 第 72 行我不理解的 Python 语法错误

问题描述

在第 72 行,我遇到了一个无效的语法错误,我和我的朋友都不确定为什么。

import random
import time

def displayIntro():
    print("Welcome to hell!")
    print("You may be wondering what you did to deserve this... you'll find out soon enough")
    print("For the momment, you have the option to pick a path.")
    print("There is path 1, which leads west through the firey lakes of damnation.")
    print("Or path 2, which leads through the desert of broken glass and aids needles.")
    print("There's also a 3rd path, but you don't wanna go down that one.")

    do_what = raw_input("> ")

    if "1" in do_what:
        print("You decide to take a swim in the firey lake of damntaion.")
        print("The flesh burns right off your skin and you drown in the lava of sin.")
        print("You die a fast, but extremely painfull death.")
        dead()

    elif "2" in do_what:
        print("You start to walk barefoot on the broken glass and aids needles.")
        print("The desert seems to be endless though, and if the dehydration doesn't kill you, the aids eventually will.")
        print("You die a slow painfull death.")
        dead()

    elif "3" in do_what:
        print("Okay, you chose the boring path.")
        print("As you walk down the empty path, you pass several doors.")
        print("You have the choice of entering one of two doors.")
        print("Door 1 has a 'Do not enter sign' hung on it.")
        print("Door 2 has a welcome sign taped to the front")

        do_what = raw_input("> ")

        if "1" in do_what:
            print("You walk in the room and see Hitler manscaping for Saddam Hussein.")
            print("They are more embarrassed than angry.")
            print("After all, it is hell, but at this point you're not sure what the torture is anymore.")
            time.sleep(2)
            room()

        elif "2" in do_what:
            print("You walk into Satans bedroom.")
            print("He's laying on the bed in a sensual manner.")
            print("As soon as he sees you, he becomes visibly excited.")
            print("Satan ********* you to death...")
            time.sleep(2)
            dead()

def room():
    print("Now you're just chilling - technically burning - in this room with Hitler and Saddam.")
    print("You do not want to spend the rest of eternity with these two ******, so you look around the room.")
    print("Eventually, you notice a pannel in the back of the room.")
    print("On an ajecent wall there is a metal door.")
    print("Or...you can go back the way you came.")
    print("(your options are: door, pannel, or back)")

    do_what = raw_input("> ")

    if "pannel" in do_what:
        print("You crawl into what seems like a bedroom.")
        print("You look up and see Satan.")
        print("He's laying on the bed in a sensual manner.")
        print("As soon as he sees you, he becomes visibly excited.")
        print("Satan *** ***** you to death...")
        time.sleep(2)
        dead()

72. elif "back" in do_what:
        print("You turn around and open the door, a bunch of big *** lions jump out and mall you to death.")
        dead()

    elif "door" in do_what:
        print("You walk through the door and are in a hazy room.")
        print("As you walk farther in you notice that you're in a bank.")
        print("You see yourself a little ways a way.")
        print("You appear to be holding a large gun. And you seem to be pointing it at the teller.")
        print("Then you hear a loud bang.")
        room2()

标签: pythonpython-2.7

解决方案


那是因为 raw_input() 被重命名为 input(),我只是在这里运行你的程序更改为 input() 而不是 raw_input(),它工作得很好。

使用:python --version Python 3.7.1


推荐阅读