停留在21点的python代码不起作用
代码中没有错误,但当我运行代码时,它并没有按照我希望的方式运行停留在21点的python代码不起作用,python,Python,代码中没有错误,但当我运行代码时,它并没有按照我希望的方式运行 elif player == '-blackjack': betted = int(input('how much would you like to gamble? : ')) your_card = random.randrange(2,21) your_drawed = random.randrange(1,12) opponent_card = random.randrange(2,21
elif player == '-blackjack':
betted = int(input('how much would you like to gamble? : '))
your_card = random.randrange(2,21)
your_drawed = random.randrange(1,12)
opponent_card = random.randrange(2,21)
opponent_drawed = random.randrange(1,12)
if betted > player_money:
print('oye you dont have this much')
pass
elif betted <= player_money:
game = True
while game:
opponent_drawed = random.randrange(1,12)
your_drawed = random.randrange(1,12)
print(' ________________________________')
print('|Your total card : ' + str(your_card))
print('|Opponents total card : ?')
print('|h to hit, s to stay.')
player = input('|________________________________')
if opponent_card < 15:
opponent_card += opponent_drawed
elif opponent_card >= 15:
pass
if player == 'h':
your_card = your_card + your_drawed
if your_card > 21:
if opponent_card > 21:
print('BOTH BUSTED! tie')
game = False
elif opponent_card <= 21:
print('BUSTED! You lost ' + str(betted))
player_money -= betted
game = False
elif your_card == 21:
if opponent_card == 21:
print('Both 21! Tie')
game = False
elif opponent_card < 21 or opponent_card > 21:
print('You win! you won ' + str(betted))
player_money += betted
game = False
elif opponent_card > 21:
if your_card > 21:
print('man opponent busted tho, you should have stayed TIE!')
game = False
elif your_card <= 21:
print('opponent busted! you won ' + str(betted))
player_money += betted
game = False
elif player == 's':
if opponent_card == 21:
if your_card == 21:
print('both 21! tie!')
game = False
elif your_card < 21:
print('opponent reached 21 in this turn you lose ' + str(betted))
player_money -= betted
game = False
elif opponent_card > 21:
print('opponent busted you win ' + str(betted))
player_money += betted
game = False
当我运行此代码时,对21点的点击起作用,但“s”按钮停留不起作用
当我试图留下来时会发生这种情况,为什么会这样?当我击球时,它会成功上升,一切正常,但只是停留部分似乎不起作用如果对手的牌<21,你需要另一个条件。啊,好的,谢谢!!!elif player=='s'下的整个块有两个条件。一个测试对手的牌是否=21,另一个测试对手的牌是否>21。你需要包括第三种可能性。