Python 代码正在运行 while 循环但不满足 while 条件

时间:2021-01-01 21:00:13

标签: python while-loop

问题:当我尝试运行此代码并说“检查”作为用户的输入时,python 代码仍在运行。我尝试通过 Pycharm 调试它以找到问题,但无济于事。所有建议将不胜感激。新年快乐

ante = 10
table = []
player_chips = 500
deck = ['H1', 'H3', 'J10', 'JQ', 'K10', 'S10', 'AS', 'AC', 'AJ']

play = ''
while play not in ['check', '4x', '3x']:
    play = (input("Check or 4x or 3x?: "))

while (play == '4x' or '3x') and player_chips >= 3 * ante:
        try:
            if play != '3x':
                print("Player bet 4x")
                play = 4 * ante
                player_chips -= play
            else:
                print("Player bet 3x")
                play = 3 * ante
                player_chips -= play
            for c in range(5):
                table.append(deck[c])
                deck.pop(c)
        except:
            print("Insufficient chips")
else:
    print("Player checked")

0 个答案:

没有答案