def 定义函数的用法

def 的用法

def dead(why):
    print why, "\nGood job!\n"
    exit(0)

def start():
    print "You are in a dark room.\n"
    print "There is a door to your right and left.\n"
    print "Which one do you take?\n"

    next = raw_input("> ")

    if next == "left":
        pass
    elif next == "right":
        pass
    else:
        dead("You stumble around the room until you starve.")

start()

当定义好函数后,在脚本最下方输入“函数名+()” 即可。

你可能感兴趣的:(python笔记)