import random import time card_list = [1,2,3,4,5,6,7,8,9,10,10,10,10] play = "y" h_s = "y" p1 = 0 p2 = 0 p3 = 0 p4 = 0 c1 = 0 c2 = 0 c3 = 0 def loss(): print ( "Your total was {}".format(p1)) if p1 >21: print( "Bust!" ) print( "You lose") print( "Would you like to play again? (y/n)") if input() == "n": play = "n" def play_again(): print( "Would you like to play again? (y/n)") def endgame(): print("You: {}".format(p1)) print("p2: {}".format(p2)) print("p3: {}".format(p3)) print("p4: {}".format(p4)) if p1 > p2: if p1 > p3: if p1 > p4: print( "You win!" ) play_again() else: loss() while play == "y": h_s = "y" p1 = 0 p2 = 0 p3 = 0 p4 = 0 c1 = 0 c2 = 0 c3 = 0 c1 = random.choice(card_list) c2 = random.choice(card_list) p1 = c1 + c2 print("You pulled a {} and a {}".format(c1,c2)) time.sleep(1) while h_s == "y": print( "Your total is {}".format(p1)) print( "Would you like to Stand or Hit? (s/h)") if input() == "h": c3 = random.choice(card_list) p1 = p1 + c3 print("You pulled a {}".format(c3)) c3 = 0 if p1 >21: loss() else: h_s = "n" c1 = random.choice(card_list) c2 = random.choice(card_list) p2 = c1 + c2 if p2 < 14: c3 = random.choice(card_list) p2 = p2 + c3 c3 = 0 c1 = random.choice(card_list) c2 = random.choice(card_list) p3 = c1 + c2 if p3 < 14: c3 = random.choice(card_list) p2 = p2 + c3 c3 = 0 c1 = random.choice(card_list) c2 = random.choice(card_list) p4 = c1 + c2 if p4 < 14: c3 = random.choice(card_list) p2 = p2 + c3 c3 = 0 if p2 >21: p2 = 0 if p3 >21: p3 = 0 if p4 >21: p4 = 0 endgame()