0

我已经在一个类中定义了 Player,但是为什么我在输入“帮助”时无法让它打印“true”?我没有收到任何错误,但它只是继续 While 循环。我只是没有看到什么吗?

Commands = { #In-game commands
    'help': help,
    'exit': exit
    }

def charactercreation():
    print("Welcome to the wasteland. What is your name? ")
    Player.name = input(">> ")
    Player.hp = 30
    Player.curhp = 30
    Player.per = 7
    Player.dr = 1
    Player.agi = 5

def isValidCMD(cmd):
    if cmd in Commands:
        return True
    return False

def main(Player): #Main function
    Player.dead = False
    while(Player.dead == False):
        input(">> ")

        if input(isValidCMD):
            print("True")

charactercreation()
main(Player)
4

1 回答 1

2

当你说

    input(">> ")

    if input(isValidCMD):
        print("True")

要求更多的输入。尝试:

    cmd = input(">> ")

    if isValidCMD(cmd):
        print("True")

反而。

于 2013-10-21T01:31:05.383 回答