import random
#Variables
hand = 0
player_hand = 0
new_draw = 0
run = “”
hit_again = “”
win = False
#Functions
def draw(draw):
draw = random.randint(1, 12)
def choose_suit():
suits = [“Spades”, “Hearts”, “Diamonds”, “Clubs”]
return random.choice(suits)
def add_hand(hand, draw):
hand += draw
def check_hand(hand, hit):
if(hit == "Yes"):
if (hand <= 21):
print("Congradulations, you have won!")
else:
print("Sorry, you have lost")
elif hit == "No":
if (hand <= 21):
print("Sorry, you have lost")
elif hand > 21:
print("Congradulations, you have won!")
print(‘Want to play? Type Yes if you do, or anything else if you do not’)
run = input()
while run == ‘Yes’:
player_hand = random.randint(1, 12)
player_suit = choose_suit()
print("Welcome! The game is blackjack, your starting hand is", player_hand, "of", player_suit)
hit_again = input("Would you like to hit again? Yes or No")
while hit_again == 'Yes' and player_hand < 21:
new_draw = random.randint(1, 12)
player_suit = choose_suit()
print("You drew a", new_draw, "of", player_suit)
player_hand += new_draw
print("You are currently at", player_hand)
if (player_hand >= 21):
break
hit_again = input("Would you like to hit again? Yes or No")
if player_hand == 21:
print("Congradulations, you have won!")
elif player_hand > 21:
print("Sorry, you have lost")
else:
new_draw = random.randint(1, 12)
player_suit = choose_suit()
print("You drew a", new_draw, "of", player_suit)
player_hand += new_draw
check_hand(player_hand, hit_again)
print("Would you like to play again? Yes or No")
run = input()
print(“END OF PROGRAM”)