geekcomputers/Python · warning · ValueError
Dealer BUST
Error message
Dealer BUST
What it means
Raised in card_manage after the player successfully hits and the dealer's strategy_trigger draw pushes the dealer's total over 21. Signals the dealer busted, so the player wins the round. It is an expected game-outcome signal implemented as an exception.
Source
Thrown at BlackJack_game/blackjack_simulate.py:554
if self.choice == "Double-down":
try:
self.player.chips.double_bet()
except ValueError as e:
print(e)
self.player.refresh_prompt()
if self.choice in ("Insurance", "Double-down", "Surrender"):
self.go_on = False
def card_manage(self):
if self.choice in ("Hit", "Double-down"):
self.player.obtain_card(self.deck)
if self.player.is_point(">", BLACK_JACK):
raise ValueError("Player BUST")
else:
self.dealer.strategy_trigger(self.deck)
if self.dealer.is_point(">", BLACK_JACK):
raise ValueError("Dealer BUST")
elif self.choice != "Surrender":
if not self.player.chips.is_insurance:
self.dealer.strategy_trigger(self.deck)
if self.dealer.is_point(">", BLACK_JACK):
raise ValueError("Dealer BUST")
self.dealer.showing()
self.player.showing()
if self.choice in ("Double-down", "Stand"):
self.go_on = False
def is_surrender(self):
if self.choice == "Surrender":
self.player.speak("Sorry, I surrender....\n")
def get_winner(self):
if self.bust:
return "Dealer" if self.player.is_point(">", BLACK_JACK) else "Player"View on GitHub (pinned to 40f4cd2652)
Solutions
- Catch ValueError around card_manage in the play loop and settle as a player win when the message is 'Dealer BUST'
- Distinguish player vs dealer bust by inspecting the message or using separate exception types
- Ensure the outer game loop continues to the next round after settlement
Example fix
// before
self.card_manage()
// after
try:
self.card_manage()
except ValueError as e:
win = 'Dealer' in str(e)
self.settle(player_wins=win) Defensive patterns
Strategy: try-catch
Try / catch
try:
self.card_manage()
except ValueError as e:
if 'Dealer BUST' in str(e):
self.settle(player_wins=True) Prevention
- Catch ValueError around card_manage for both bust messages
- Route all bust outcomes through one settlement function
- Never let bust exceptions escape the per-round loop
When it happens
Trigger: Player chooses Hit/Double-down, does not bust, then dealer.strategy_trigger(deck) draws cards per dealer rules until the dealer exceeds 21, triggering is_point('>', BLACK_JACK).
Common situations: Dealer forced to hit on 16 and drawing a face card; simulations that don't catch the error will abort the whole game loop.
Related errors
- Player BUST
- Not enough chips
- Your integer should bigger than 0
- Your chips should between 1 -
- Parameter n must be greater or equal to one.
AI-assisted analysis of geekcomputers/Python@40f4cd2652 (2026-08-27).
Data as JSON: /api/errors/43b56c196e7a4f48.
Report an issue: GitHub.