小编Jef*_*ves的帖子

破坏提示,简单的if语句?(蟒蛇)

def prompt():
    x = raw_input('Type a command: ')
    return x


def nexus():
    print 'Welcome to the Nexus,', RANK, '. Are you ready to fight?';
    print 'Battle';
    print 'Statistics';
    print 'Shop';
    command = prompt()
    if command == "Statistics" or "Stats" or "Stat":
        Statistics()
    elif command == "Battle" or "Fight":
        Battle()
    elif command == "Shop" or "Buy" or "Trade":
        Shop()
    else:
        print "I can't understand that..."
        rankcheck()
Run Code Online (Sandbox Code Playgroud)

实际上,应该做的是在输入stat时输入Stat功能,输入Battle时输入Battle功能,输入shop时输入shop功能.然而,我实际上遇到了问题(Duh).当输入任何内容时,它会直接转到Stat函数.我相信这是因为我处理提示的方式.它几乎只看到第一个if语句并呈现它应该的函数.但是,如果我输入Battle,它仍然需要我进行统计.

我是Python的新手,我来这里是为了寻求一些建议.这有什么想法?提前致谢.

python if-statement

2
推荐指数
1
解决办法
166
查看次数

标签 统计

if-statement ×1

python ×1