Skip to content
Sign upLog in
← Back to Community

how do i fix this error. (repl process died unexpectedly)

Profile icon
hadthelad

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

repl error i dont understand

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

here is the code:
https://repl.it/@hadthelad/blackjack

Answered by UniqueOstrich18 [earned 5 cycles]
View Answer
Voters
Profile icon
ManishKumar286
Profile icon
11irishjs
Profile icon
JawadShareef
Profile icon
oscarcanney
Profile icon
NattaponSripoom
Profile icon
wilystoat
Profile icon
STUDENT-Kimberl
Profile icon
HunterWynn
Profile icon
ehyihfiuehfuewhuofhewofhweou
Profile icon
ben66990
Comments
hotnewtop
Profile icon
UniqueOstrich18

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.

Example:

try: while True: if input("Exit? ") == "yes": 1/0 except: pass

Output:

image

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

try: import random deck = list('234567890JQKA') random.shuffle(deck) 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: dealer_cards.append(random.randint(1,5)) 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:)') 1/0 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) player_cards.append(new_card) if sum(player_cards) > 21: print('\n you bust, the dealer automatically wins', player_cards) 1/0 else: 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:)') 1/0 def dealer_play(): print("Dealer had a total of " + str(sum(dealer_cards))); while(sum(dealer_cards) < 17): dealer_cards.append(random.randint(1,13)) print("Dealer's total is now " + str(sum(dealer_cards))); 1/0 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)) 1/0 dealer_play() while sum(dealer_cards) < 21: if sum(dealer_cards) > sum(player_cards): print('you lost to the dealer' ) 1/0 elif sum(dealer_cards) == sum(player_cards): print('you and the dealer tied', 'dealer =', sum(dealer_cards), 'player =', sum(player_cards)) 1/0 while sum(player_cards) < 21: if sum(player_cards) > sum(dealer_cards): print('congratulations you won') 1/0 except: pass

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.

Profile icon
hadthelad

@UniqueOstrich18

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

Profile icon
UniqueOstrich18

@hadthelad
You're welcome

Profile icon
TheBestTaran

@hadthelad
please do not spam your questions, does not matter replit or mail.

Profile icon
leon332157

@hadthelad
Then you should avoid using exit() at all because of how repl.it 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.

Profile icon
Scoder12

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

Profile icon
sylashur

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()