Ask coding questions

← Back to all posts
how do i fix this error. (repl process died unexpectedly)
hadthelad (11)

so im nearly done with my game except for one error which is every time i for an example bust, its supposed to come up with a string saying that you busted, but it doesnt do that, instead it just comes up with this error

so if you guys could tell me how to fix it that would be very helpful.

here is the code:

Answered by UniqueOstrich18 (310) [earned 5 cycles]
View Answer
UniqueOstrich18 (310)

You can fix this issue by putting the entire program into a try: except: block and running 1/0 to raise an error. Since the program is in the try: except: block, there will be no error message and the program will return and end.


  while True:
    if input("Exit? ") == "yes":


Here's your fixed program: (I also removed some empty lines.)

  import random

  deck = list('234567890JQKA')
  value = {'2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8,'9':9, '0':10, 'J':11, 'Q':12, 'K':13, 'A':1}
  player_win = 0
  player_losses = 0
  dealer_cards = []
  player_cards = []

  while len(dealer_cards) != 2:

    if len(dealer_cards) == 2:
      print("Dealer has X &", dealer_cards[1])

  while len(player_cards) != 2:
    player_cards.append(random.randint(1, 5))
    if len(player_cards) == 2:
      print('you have a total of:', sum(player_cards), 'from these cards:', player_cards)
      if sum(player_cards) == 21:
        print('you have 21 you got blackjack, well done:)') 
    player = [deck.pop() for _ in range(2)]
    cpu = [deck.pop() for _ in range(2)]

  if sum(player_cards) < 21:
    action = input('do you want to hit or stay:')
    while action == 'hit':
      new_card = random.randint(1, 13)
      if sum(player_cards) > 21:
        print('\n you bust, the dealer automatically wins', player_cards)
        print("You now have a total of " + str(sum(player_cards)) + " from these cards", player_cards)
        action = input("Do you want to stay or hit? ")
    if action == 'stay':
      print('your total sum was:', sum(player_cards), '\n the dealer will play now')
  if sum(player_cards) == 21:
    print('you have 21 you got blackjack, well done:)')

  def dealer_play():
    print("Dealer had a total of " + str(sum(dealer_cards)));
    while(sum(dealer_cards) < 17):
      print("Dealer's total is now " + str(sum(dealer_cards)));
      if(sum(dealer_cards) > 21):
        print("Dealer bust, you win!," "dealer =", sum(dealer_cards), "player =", sum(player_cards))
    if sum(dealer_cards) == 21:
      print('the dealer got blackjack', sum(dealer_cards))


  while sum(dealer_cards) < 21:
    if sum(dealer_cards) > sum(player_cards):
      print('you lost to the dealer' )
    elif sum(dealer_cards) == sum(player_cards):
      print('you and the dealer tied', 'dealer =', sum(dealer_cards), 'player =', sum(player_cards))

  while sum(player_cards) < 21:
    if sum(player_cards) > sum(dealer_cards):
    print('congratulations you won')

If this was helpful, please mark it as the answer.

Note: You had a post about the same question that you deleted, which I had an answer in. I had to retype the entire comment here.

hadthelad (11)

yea it worked thank you a lot for helping me (sorry im still kinda new)

leon332157 (218)

@hadthelad Then you should avoid using exit() at all because of how detects a process running. You should use break in a while loop instead of exit() Also please don't spam multiple posts about the same question.

Scoder12 (771)

This happens whenever you use sys.exit and can't be avoided sadly.

sylashur (48)

I don't see an issue regarding busting, the bust message comes up and then the error message comes up, if you don't want the error message you could use methods other than sys.exit()