我是 python 新手,我应该创建一个游戏,其中输入只能在 1 和 3 的范围内。(玩家 1、2、3)如果用户输入超过 3,则输出应该是错误的,如果它是错误的在字符串中。
def makeTurn(player0):
ChoosePlayer= (raw_input ("Who do you want to ask? (1-3)"))
if ChoosePlayer > 4:
print "Sorry! Error! Please Try Again!"
ChoosePlayer= (raw_input("Who do you want to ask? (1-3)"))
if ChoosePlayer.isdigit()== False:
print "Sorry! Integers Only"
ChoosePlayer = (raw_input("Who do you want to ask? (1-3)"))
else:
print "player 0 has chosen player " + ChoosePlayer + "!"
ChooseCard= raw_input("What rank are you seeking from player " + ChoosePlayer +"?")
我是这样做的,但问题是我的代码似乎有问题。如果输入是 1,它仍然说“错误请重试”我很困惑!