小编use*_*342的帖子

以艰难的方式学习python - 练习36个功能问题

我正在学习如何通过学习python的方式进行编码,而且我最近第一次陷入困境.对于这个练习,我们应该编写自己的游戏.我这样做了,但出于某种原因,每当我运行它时,right_room()函数在我输入答案后退出,而不是进入下一个房间.任何帮助将不胜感激.这是我的代码:

from sys import exit

def bear_room():
    print "You are in a room with a bear."
    print "You have two choices. left or right?"
    next = raw_input("> ")

    if next == "left":
        left_room()
    elif next == "right":
        right_room()
    else:
        print "No idea what that means..."

def left_room():
    print "You went left."
    print "There are two doors. right or straight"
    next = raw_input("> ")

    if next == "right":
        bear_room()
    elif next == "straight":
        second_left()
    else:
        print "What are you saying, bro?" …
Run Code Online (Sandbox Code Playgroud)

python

4
推荐指数
1
解决办法
639
查看次数

标签 统计

python ×1