i have a working blackjack program that hates me. it was working yesterday, but when i go to hand it in today, it breaks. the computer keeps drawing cards, even if they are wining, after the user busts once. this doesn’t happen if the user doesn’t bust before the computer wins. ill put the code here, but be warned its a mess of 800 lines.
heres a look at what it is doing:
Let’s continue. What is your bet?
1
8 of Hearts 4 of Diamonds
8 4
12
Hit, or stay?
s
The computer drew a Jack of Spades and a 2 of Hearts
The computer’s total is 12
The computer hits, drawing the 4 of Spades bringing their total to 16
The computer hits, drawing the Jack of Clubs bringing their total to 26
The computer busts! They ended on a total of 26
Press 1 to continue the game, or 2 to back out.
import random
wallet = 0
wallet_total = 0
comp_wallet_total = 0
comp_wallet = 0
bet = 5
suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
card_num_one = 0
card_num_two = 0
card_num_three = 0
card_num_four = 0
card_num_five = 0
card_num_six = 0
card_num_seven = 0
card_suit_one = 0
card_suit_two = 0
card_suit_three = 0
card_suit_four = 0
card_suit_five = 0
card_suit_six = 0
card_suit_seven = 0
card_value_one = 0
card_value_two = 0
card_value_three = 0
card_value_four = 0
card_value_five = 0
card_value_six = 0
card_value_seven = 0
card_value_total = 0
card_one = ""
card_two = ""
card_three = ""
card_four = ""
card_five = ""
card_six = ""
card_seven = ""
cmp_card_num_one = 0
cmp_card_num_two = 0
cmp_card_num_three = 0
cmp_card_num_four = 0
cmp_card_num_five = 0
cmp_card_num_six = 0
cmp_card_suit_one = 0
cmp_card_suit_two = 0
cmp_card_suit_three = 0
cmp_card_suit_four = 0
cmp_card_suit_five = 0
cmp_card_suit_six = 0
cmp_card_value_one = 0
cmp_card_value_two = 0
cmp_card_value_three = 0
cmp_card_value_four = 0
cmp_card_value_five = 0
cmp_card_value_six = 0
cmp_card_value_total = 0
cmp_card_one = ""
cmp_card_two = ""
cmp_card_three = ""
cmp_card_four = ""
cmp_card_five = ""
cmp_card_six = ""
def wallet_cal():
global wallet
global wallet_total
global comp_wallet
global comp_wallet_total
global bet
wallet = wallet_total
comp_wallet = comp_wallet_total
if comp_wallet == 0:
win()
elif wallet == 0:
lose()
elif wallet > 0 and comp_wallet > 0:
print("You have $" + str(wallet) + " in your wallet.")
blkjack_next_round()
def start():
global wallet, comp_wallet, wallet_total, comp_wallet_total
wallet = 50
comp_wallet = 50
wallet_total = 50
comp_wallet_total = 50
rule_book()
def rule_book():
global wallet, wallet_total, comp_wallet, comp_wallet_total
wallet = wallet_total
comp_wallet = comp_wallet_total
print("Objective: be the first player to get to 100 gold")
print("Setup: Each player will start with 50 coins. at the start of every round, you automatically bet 5 coins.")
print("You can raise that bet before cards are given.")
print("\n\nYou will be given two cards at the start of the round. The card will go from one to ten. Face cards will equal 10. Aces will equal 1.")
print("The goal of each round is to get closer to 21 than your opponent, without going over.")
print("\n\nControls:")
print("To get another card, hit 'H'. To keep your current cards, hit 'S'.")
blkjack_comp()
def blkjack_comp():
global wallet, bet, wallet_total, comp_wallet, comp_wallet_total
wallet = wallet_total
comp_wallet = comp_wallet_total
print("What would you like to be called?")
user_name = input()
print("\nWelcome", user_name)
print("Let's begin. What is your starting bet?")
bet = int(input())
if bet > wallet:
over_bet()
else:
blkjack_comp_deal()
def blkjack_next_round():
global wallet, bet, wallet_total, comp_wallet, comp_wallet_total
wallet = wallet_total
comp_wallet = comp_wallet_total
if comp_wallet == 0:
win()
elif wallet == 0:
lose()
else:
print("Let's continue. What is your bet?")
bet = int(input())
if bet > wallet:
over_bet()
else:
blkjack_comp_deal()
def over_bet():
global wallet, bet
print("You do not have enough coins for that bet. You have", wallet, "coins left")
print("What is your starting bet?")
bet = int(input())
if bet > wallet:
over_bet()
else:
blkjack_comp_deal()
def blkjack_comp_deal():
global card_num_one, card_num_two, card_suit_one, card_suit_two
card_suit_one = random.randint(1, 4) # For suit
card_num_one = random.randint(1, 13) # For number
card_suit_two = random.randint(1, 4) # For suit
card_num_two = random.randint(1, 13) # For number
if card_suit_one == card_suit_two and card_num_one == card_num_two:
blkjack_comp_deal()
else:
card_maker_deal()
def card_maker_deal():
global card_num_one, card_num_two, card_one, card_two, card_suit_one, card_suit_two
card_one = get_card_name(card_suit_one, card_num_one)
card_two = get_card_name(card_suit_two, card_num_two)
print(card_one, card_two)
hit_or_stay_one()
def get_card_name(suit_index, number):
# Function to convert suit index and number to card name
suit = suits[suit_index - 1]
if number == 1:
card_name = "Ace of " + suit
elif 2 <= number <= 10:
card_name = str(number) + " of " + suit
elif number == 11:
card_name = "Jack of " + suit
elif number == 12:
card_name = "Queen of " + suit
elif number == 13:
card_name = "King of " + suit
else:
card_name = "Invalid Card"
blkjack_comp_deal()
return card_name
def hit_or_stay_one():
global card_one, card_two, card_num_one, card_num_two, card_value_one, card_value_two
if 2 <= card_num_one <= 9:
card_value_one = card_num_one
elif card_num_one in (10, 11, 12, 13):
card_value_one = 10
elif card_num_one == 1:
card_value_one = 1
if 2 <= card_num_two <= 9:
card_value_two = card_num_two
elif card_num_two in (10, 11, 12, 13):
card_value_two = 10
elif card_num_two == 1:
card_value_two = 1
card_value_total = (card_value_one + card_value_two)
print(card_value_one, card_value_two)
print(card_value_total)
print("Hit, or stay?")
card_choice_one = str(input())
if card_choice_one == "h":
hit_one()
elif card_choice_one == "s":
stay()
elif card_choice_one not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_or_stay_one()
def hit_one():
global card_suit_three, card_num_three, card_three, card_value_one, card_value_two, card_value_three, card_value_total, card_num_one, card_suit_one, card_num_two, card_suit_two
card_suit_three = random.randint(1, 4) # For suit
card_num_three = random.randint(1, 13) # For number
if card_suit_three == card_suit_two and card_num_three == card_num_two:
hit_one()
if card_suit_one == card_suit_three and card_num_one == card_num_three:
hit_one()
else:
card_three = get_card_name(card_suit_three, card_num_three)
if 2 <= card_num_three <= 9:
card_value_three = card_num_three
elif card_num_three in (10, 11, 12, 13):
card_value_three = 10
elif card_num_three == 1:
card_value_three = 1
card_value_total = (card_value_one + card_value_two + card_value_three)
print("You drew a", card_three, "bringing your total to", card_value_total)
if card_value_total > 21:
broken()
else:
print("Hit, or stay?")
card_choice_two = str(input())
if card_choice_two == "h":
hit_two()
elif card_choice_two == "s":
stay()
elif card_choice_two not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_one_error()
def hit_one_error():
card_choice_two = str(input())
if card_choice_two == "h":
hit_two()
elif card_choice_two == "s":
stay()
elif card_choice_two not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_one_error()
def hit_two():
global card_value_four, card_suit_four, card_num_four, card_four, card_suit_three, card_num_three, card_three, card_value_one, card_value_two, card_value_three, card_value_total, card_num_one, card_suit_one, card_num_two, card_suit_two
card_suit_four = random.randint(1, 4) # For suit
card_num_four = random.randint(1, 13) # For number
if card_suit_four == card_suit_two and card_num_four == card_num_two:
hit_two()
elif card_suit_one == card_suit_four and card_num_one == card_num_four:
hit_two()
elif card_suit_three == card_suit_four and card_num_three == card_num_four:
hit_two()
else:
card_four = get_card_name(card_suit_four, card_num_four)
if 2 <= card_num_four <= 9:
card_value_four = card_num_four
elif card_num_four in (10, 11, 12, 13):
card_value_four = 10
elif card_num_four == 1:
card_value_four = 1
card_value_total = (card_value_one + card_value_two + card_value_three + card_value_four)
print("You drew a", card_four, "bringing your total to", card_value_total)
if card_value_total > 21:
broken()
else:
print("Hit, or stay?")
card_choice_three = str(input())
if card_choice_three == "h":
hit_three()
elif card_choice_three == "s":
stay()
elif card_choice_three not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_two_error()
def hit_two_error():
card_choice_three = str(input())
if card_choice_three == "h":
hit_three()
elif card_choice_three == "s":
stay()
elif card_choice_three not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_two_error()
def hit_three():
global card_value_four, card_suit_five, card_num_five, card_five, card_value_five, card_suit_four, card_num_four, card_four, card_suit_three, card_num_three, card_three, card_value_one, card_value_two, card_value_three, card_value_total, card_num_one, card_suit_one, card_num_two, card_suit_two
card_suit_five = random.randint(1, 4) # For suit
card_num_five = random.randint(1, 13) # For number
if card_suit_five == card_suit_two and card_num_five == card_num_two:
hit_three()
elif card_suit_one == card_suit_five and card_num_one == card_num_five:
hit_three()
elif card_suit_three == card_suit_five and card_num_three == card_num_five:
hit_three()
elif card_suit_four == card_suit_five and card_num_four == card_num_five:
hit_three()
else:
card_five = get_card_name(card_suit_five, card_num_five)
if 2 <= card_num_five <= 9:
card_value_five = card_num_five
elif card_num_five in (10, 11, 12, 13):
card_value_five = 10
elif card_num_five == 1:
card_value_five = 1
card_value_total = (card_value_one + card_value_two + card_value_three + card_value_four + card_value_five)
print("You drew a", card_five, "bringing your total to", card_value_total)
if card_value_total > 21:
broken()
else:
print("Hit, or stay?")
card_choice_four = str(input())
if card_choice_four == "h":
hit_four()
elif card_choice_four == "s":
stay()
elif card_choice_four not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_four_error()
def hit_four_error():
card_choice_four = str(input())
if card_choice_four == "h":
hit_four()
elif card_choice_four == "s":
stay()
elif card_choice_four not in ("h", "s"):
print("Press 's' to stay, or 'h' to hit")
hit_four_error()
def hit_four():
global card_six, card_value_four, card_suit_six, card_value_six, card_num_six, card_suit_five, card_num_five, card_five, card_value_five, card_suit_four, card_num_four, card_four, card_suit_three, card_num_three, card_three, card_value_one, card_value_two, card_value_three, card_value_total, card_num_one, card_suit_one, card_num_two, card_suit_two
card_suit_six = random.randint(1, 4) # For suit
card_num_six = random.randint(1, 13) # For number
if card_suit_six == card_suit_two and card_num_six == card_num_two:
hit_four()
elif card_suit_one == card_suit_six and card_num_one == card_num_six:
hit_four()
elif card_suit_three == card_suit_six and card_num_three == card_num_six:
hit_four()
elif card_suit_four == card_suit_six and card_num_four == card_num_six:
hit_four()
elif card_suit_five == card_suit_six and card_num_five == card_num_six:
hit_four()
else:
card_six = get_card_name(card_suit_six, card_num_six)
if 2 <= card_num_six <= 9:
card_value_six = card_num_six
elif card_num_six in (10, 11, 12, 13):
card_value_six = 10
elif card_num_six == 1:
card_value_six = 1
card_value_total = (card_value_one + card_value_two + card_value_three + card_value_four + card_value_five + card_value_six)
print("You drew a", card_six, "bringing your total to", card_value_total)
if card_value_total > 21:
broken()
else:
stay()
def stay():
global card_value_on, card_value_two, card_value_three, card_value_four, card_value_five, card_value_six, card_one, card_two, card_three, card_four, card_five, card_six, cmp_card_num_one, cmp_card_num_two, cmp_card_num_three, cmp_card_num_four, cmp_card_num_five, cmp_card_num_six, cmp_card_suit_one, cmp_card_suit_two, cmp_card_suit_three, cmp_card_suit_four, cmp_card_suit_five, cmp_card_suit_six, cmp_card_value_one, cmp_card_value_two, cmp_card_value_three, cmp_card_value_four, cmp_card_value_five, cmp_card_value_six, cmp_card_value_total, cmp_card_one, cmp_card_two, cmp_card_three, cmp_card_four, cmp_card_five, cmp_card_six, card_value_total
cmp_card_one_num = random.randint(1, 13)
cmp_card_one_suit = random.randint(1, 4)
cmp_card_two_num = random.randint(1, 13)
cmp_card_two_suit = random.randint(1, 4)
cmp_card_three_num = random.randint(1, 13)
cmp_card_three_suit = random.randint(1, 4)
cmp_card_four_num = random.randint(1, 13)
cmp_card_four_suit = random.randint(1, 4)
cmp_card_five_num = random.randint(1, 13)
cmp_card_five_suit = random.randint(1, 4)
cmp_card_six_num = random.randint(1, 13)
cmp_card_six_suit = random.randint(1, 4)
duplicate_cards = set()
while len(duplicate_cards) < 13:
cmp_card_one_num = random.randint(1, 13)
cmp_card_one_suit = random.randint(1, 4)
cmp_card_two_num = random.randint(1, 13)
cmp_card_two_suit = random.randint(1, 4)
cmp_card_three_num = random.randint(1, 13)
cmp_card_three_suit = random.randint(1, 4)
cmp_card_four_num = random.randint(1, 13)
cmp_card_four_suit = random.randint(1, 4)
cmp_card_five_num = random.randint(1, 13)
cmp_card_five_suit = random.randint(1, 4)
cmp_card_six_num = random.randint(1, 13)
cmp_card_six_suit = random.randint(1, 4)
duplicate_cards = {
(cmp_card_one_num, cmp_card_one_suit),
(cmp_card_two_num, cmp_card_two_suit),
(cmp_card_three_num, cmp_card_three_suit),
(cmp_card_four_num, cmp_card_four_suit),
(cmp_card_five_num, cmp_card_five_suit),
(cmp_card_six_num, cmp_card_six_suit),
(card_num_one, card_suit_one),
(card_num_two, card_suit_two),
(card_num_three, card_suit_three),
(card_num_four, card_suit_four),
(card_num_five, card_suit_five),
(card_num_six, card_suit_six),
(card_num_seven, card_suit_seven)
}
cmp_card_one = get_card_name(cmp_card_one_suit, cmp_card_one_num)
cmp_card_two = get_card_name(cmp_card_two_suit, cmp_card_two_num)
cmp_card_three = get_card_name(cmp_card_three_suit, cmp_card_three_num)
cmp_card_four = get_card_name(cmp_card_four_suit, cmp_card_four_num)
cmp_card_five = get_card_name(cmp_card_five_suit, cmp_card_five_num)
cmp_card_six = get_card_name(cmp_card_six_suit, cmp_card_six_num)
# Calculate card values for each variable
# Process card_num_one
# Process cmp_card_one
if 2 <= cmp_card_one_num <= 9:
cmp_card_value_one = cmp_card_one_num
elif cmp_card_one_num in (10, 11, 12, 13):
cmp_card_value_one = 10
elif cmp_card_one_num == 1:
cmp_card_value_one = 1
# Process cmp_card_two
if 2 <= cmp_card_two_num <= 9:
cmp_card_value_two = cmp_card_two_num
elif cmp_card_two_num in (10, 11, 12, 13):
cmp_card_value_two = 10
elif cmp_card_two_num == 1:
cmp_card_value_two = 1
# Process cmp_card_three
if 2 <= cmp_card_three_num <= 9:
cmp_card_value_three = cmp_card_three_num
elif cmp_card_three_num in (10, 11, 12, 13):
cmp_card_value_three = 10
elif cmp_card_three_num == 1:
cmp_card_value_three = 1
# Process cmp_card_four
if 2 <= cmp_card_four_num <= 9:
cmp_card_value_four = cmp_card_four_num
elif cmp_card_four_num in (10, 11, 12, 13):
cmp_card_value_four = 10
elif cmp_card_four_num == 1:
cmp_card_value_four = 1
# Process cmp_card_five
if 2 <= cmp_card_five_num <= 9:
cmp_card_value_five = cmp_card_five_num
elif cmp_card_five_num in (10, 11, 12, 13):
cmp_card_value_five = 10
elif cmp_card_five_num == 1:
cmp_card_value_five = 1
# Process cmp_card_six
if 2 <= cmp_card_six_num <= 9:
cmp_card_value_six = cmp_card_six_num
elif cmp_card_six_num in (10, 11, 12, 13):
cmp_card_value_six = 10
elif cmp_card_six_num == 1:
cmp_card_value_six = 1
if 2 <= card_num_one <= 9:
card_value_one = card_num_one
elif card_num_one in (10, 11, 12, 13):
card_value_one = 10
elif card_num_one == 1:
card_value_one = 1
# Process card_num_two
if 2 <= card_num_two <= 9:
card_value_two = card_num_two
elif card_num_two in (10, 11, 12, 13):
card_value_two = 10
elif card_num_two == 1:
card_value_two = 1
# Process card_num_three
if 2 <= card_num_three <= 9:
card_value_three = card_num_three
elif card_num_three in (10, 11, 12, 13):
card_value_three = 10
elif card_num_three == 1:
card_value_three = 1
# Process card_num_four
if 2 <= card_num_four <= 9:
card_value_four = card_num_four
elif card_num_four in (10, 11, 12, 13):
card_value_four = 10
elif card_num_four == 1:
card_value_four = 1
# Process card_num_five
if 2 <= card_num_five <= 9:
card_value_five = card_num_five
elif card_num_five in (10, 11, 12, 13):
card_value_five = 10
elif card_num_five == 1:
card_value_five = 1
# Process card_num_six
if 2 <= card_num_six <= 9:
card_value_six = card_num_six
elif card_num_six in (10, 11, 12, 13):
card_value_six = 10
elif card_num_six == 1:
card_value_six = 1
card_value_total = (card_value_one + card_value_two + card_value_three + card_value_four + card_value_five + card_value_six)
#print(card_value_one, card_value_two, card_value_three, card_value_four, card_value_five, card_value_six)
cmp_card_value_total = (cmp_card_value_one + cmp_card_value_two)
print("The computer drew a", cmp_card_one, "and a", cmp_card_two)
print("The computer's total is", cmp_card_value_total)
if card_value_total >= cmp_card_value_total and cmp_card_value_total < 21:
cmp_card_value_total = (cmp_card_value_one + cmp_card_value_two + cmp_card_value_three)
print("The computer hits, drawing the", cmp_card_three, "bringing their total to", cmp_card_value_total)
if card_value_total >= cmp_card_value_total and cmp_card_value_total < 21:
cmp_card_value_total = (cmp_card_value_one + cmp_card_value_two + cmp_card_value_three + cmp_card_value_four)
print("The computer hits, drawing the", cmp_card_four, "bringing their total to", cmp_card_value_total)
if card_value_total >= cmp_card_value_total and cmp_card_value_total < 21:
cmp_card_value_total = (cmp_card_value_one + cmp_card_value_two + cmp_card_value_three + cmp_card_value_four + cmp_card_value_five)
print("The computer hits, drawing the", cmp_card_five, "bringing their total to", cmp_card_value_total)
if card_value_total >= cmp_card_value_total and cmp_card_value_total < 21:
cmp_card_value_total = (cmp_card_value_one + cmp_card_value_two + cmp_card_value_three + cmp_card_value_four + cmp_card_value_five + cmp_card_value_six)
print("The computer hits, drawing the", cmp_card_six, "bringing their total to", cmp_card_value_total)
if card_value_total < cmp_card_value_total and cmp_card_value_total <= 21:
print("The computer wins! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif cmp_card_value_total > 21:
print("The computer busts! They ended on a total of", cmp_card_value_total)
comp_bust()
elif cmp_card_value_total < card_value_total:
print("the computer loses! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif card_value_total < cmp_card_value_total and cmp_card_value_total <= 21:
print("The computer wins! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif cmp_card_value_total > 21:
print("The computer busts! They ended on a total of", cmp_card_value_total)
comp_bust()
elif card_value_total < cmp_card_value_total and cmp_card_value_total <= 21:
print("The computer wins! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif cmp_card_value_total > 21:
print("The computer busts! They ended on a total of", cmp_card_value_total)
comp_bust()
elif card_value_total < cmp_card_value_total and cmp_card_value_total <= 21:
print("The computer wins! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif cmp_card_value_total > 21:
print("The computer busts! They ended on a total of", cmp_card_value_total)
comp_bust()
elif card_value_total < cmp_card_value_total and cmp_card_value_total <= 21:
print("The computer wins! They ended on a score of", cmp_card_value_total, "while you ended on a score of", card_value_total)
comp_win()
elif cmp_card_value_total > 21:
print("The computer busts! They ended on a total of", cmp_card_value_total)
comp_bust()
#print(cmp_card_one, cmp_card_two, cmp_card_three, cmp_card_four, cmp_card_five, cmp_card_six)
def broken():
global card_value_total, wallet, bet, wallet_total, comp_wallet, comp_wallet_total
wallet_total = (wallet - bet)
comp_wallet_total = (comp_wallet + bet)
print("Round Over: you went over 21. your final amount was", card_value_total, ". You lost", bet, "Your wallet is now", wallet_total)
print("Press 1 to continue the game, or 2 to back out.")
while True:
try:
continue_game = int(input())
break # Exit the loop if the input is successfully converted
except ValueError:
print("Invalid input. Press 1 to continue the game, or 2 to back out.")
if continue_game == 1:
wallet_cal()
if continue_game == 2:
back_out()
elif continue_game not in (1, 2):
broken_error()
def broken_error():
print("Press 1 to continue the game, or 2 to back out.")
continue_game = int(input())
if continue_game == 1:
wallet_cal()
if continue_game == 2:
back_out()
elif continue_game not in (1, 2):
broken_error()
def back_out():
print("You have left the game. Your final amount was", card_value_total, ". You lost", bet, "Your wallet is now", wallet_total)
exit()
def comp_win():
global bet, wallet, wallet_total, comp_wallet, comp_wallet_total
wallet_total = (wallet - bet)
comp_wallet_total = (comp_wallet + bet)
print("Press 1 to continue the game, or 2 to back out.")
while True:
try:
continue_game = int(input())
break # Exit the loop if the input is successfully converted
except ValueError:
print("Invalid input. Press 1 to continue the game, or 2 to back out.")
if continue_game == 1:
wallet_cal()
if continue_game == 2:
back_out()
else:
repeat_error()
def repeat_error():
print("Press 1 to continue the game, or 2 to back out.")
while True:
try:
continue_game = int(input())
break # Exit the loop if the input is successfully converted
except ValueError:
print("Invalid input. Press 1 to continue the game, or 2 to back out.")
if continue_game == 1:
wallet_cal()
if continue_game == 2:
back_out()
else:
repeat_error()
def comp_bust():
global bet, wallet, wallet_total, comp_wallet, comp_wallet_total
wallet_total = (wallet + bet)
comp_wallet_total = (comp_wallet - bet)
print("Press 1 to continue the game, or 2 to back out.")
while True:
try:
continue_game = int(input())
break # Exit the loop if the input is successfully converted
except ValueError:
print("Invalid input. Press 1 to continue the game, or 2 to back out.")
if continue_game == 1:
wallet_cal()
if continue_game == 2:
back_out()
else:
repeat_error()
def win():
print("Congratulation! You beat the computer. Play again? Press 1 to play, or 2 to exit.")
play_again = int(input())
if play_again == 1:
start()
elif play_again == 2:
print("Come again!")
exit()
elif play_again not in (1, 2):
play_again_choice()
def lose():
print("The computer wins, leaving you broke. But, we can always give you a loan? Play again? Press 1 to play, or 2 to exit.")
play_again = int(input())
if play_again == 1:
start()
elif play_again == 2:
print("Come again!")
exit()
elif play_again not in (1, 2):
play_again_choice()
def play_again_choice():
print("Press 1 to play, or 2 to exit.")
play_again = int(input())
if play_again == 1:
start()
elif play_again == 2:
print("Come again!")
exit()
elif play_again not in (1, 2):
play_again_choice()
start()