我已经在课程中定义了Player,但是每当我输入“help”时,为什么我不能让它打印“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)
答案 0 :(得分:2)
当你说
时 input(">> ")
if input(isValidCMD):
print("True")
你要求更多输入。尝试:
cmd = input(">> ")
if isValidCMD(cmd):
print("True")
代替。