我正在尝试检查一些条件的输入,然后将字符串转换为整数,在此之后我想确保整数不是负数,否则提示用户再次输入。
它适用于字符串条件,但是当我输入负数时,输入会引发错误“输入预计最多 1 个参数,得到 2”
关于如何评估这一点的任何想法?
#This compares whether the bet placed is greater than the value in the players chip_balance. It prompts the player for a lower bet if it is of greater value than chip_balance
while bet > chip_balance:
print('Sorry, you may only bet what you have 0 -', chip_balance)
bet = input("Place your bet: ")
while bet == '':
bet = input("Can't be an empty bet please try again ")
while bet.isalpha() or bet == '':
bet = input("Must be a numerical value entered \n \n Place You're bet:")
bet = int(bet)
if bet < 0:
bet = input("Sorry, you may only bet what you have sir! 0 \-", chip_balance)
bet = int(bet)
拉丁的传说
相关分类