import random import time dscore = 0 score = 0 print("██████╗ ██╗ █████╗ ██████╗██╗ ██╗") print("██╔══██╗██║ ██╔══██╗██╔════╝██║ ██╔╝") print("██████╔╝██║ ███████║██║ █████╔╝") print("██╔══██╗██║ ██╔══██║██║ ██╔═██╗") print("██████╔╝███████╗██║ ██║╚██████╗██║ ██╗") print("╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝") time.sleep(0.5) print(" ██╗ █████╗ ██████╗██╗ ██╗") print(" ██║██╔══██╗██╔════╝██║ ██╔╝") print(" ██║███████║██║ █████╔╝") print("██ ██║██╔══██║██║ ██╔═██╗") print("╚█████╔╝██║ ██║╚██████╗██║ ██╗") print(" ╚════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝") time.sleep(2) print("----------------------------------") card_list = ["King", "Queen", "Jack", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Ace"] values = { "King": 10, "Queen": 10, "Jack": 10, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "Ace": 1 } print("Your first two cards are:") for i in range(2) : random.shuffle(card_list) card = random.choice(card_list) card_value = values[card] print(card) if card == "Ace": print("You got a Ace!!!") time.sleep(1) while True: answer = int(input("Would you like it to be a 1 or 11? ")) if answer == 1 : card_value = 1 break else : card_value = 11 break score += card_value print(f"Your score is: {score}") time.sleep(1) print("-----------------") print("The dealers first card is a...") for i in range(1) : random.shuffle(card_list) card = random.choice(card_list) card_value = values[card] print(card) dscore += card_value print(f"Dealers score is: {dscore}") print() time.sleep(1) while score < 21: choice = input("Would you like to [h]it or [s]tand: ") if choice == "h": random.shuffle(card_list) card = random.choice(card_list) card_value = values[card] print("-----------------") print(f"You got a {card}") if card == "Ace": print("You got an Ace!!!") while True: answer = input("Would you like it to be a 1 or 11? ") if answer == "1": card_value = 1 break elif answer == "11": card_value = 11 break else: print("Please enter either 1 or 11.") score += card_value print(f"Your score is: {score}") elif choice == "s": print("You decide to stand...") break else: print("Invalid choice. Please enter 'h' for hit or 's' for stand.") if score <= 21: print("The dealer's turn...") time.sleep(1) while dscore < 17: random.shuffle(card_list) card = random.choice(card_list) card_value = values[card] print(f"Dealer got a {card}.") time.sleep(1) dscore += card_value print(f"Dealer's score is: {dscore}") print(f"Your final score is: {score}") time.sleep(2) print(f"Dealer's final score is: {dscore}") if score > 21: print("You busted! Dealer wins.") elif dscore > 21: print("Dealer busted! You win.") elif score > dscore: print("You win!") elif score < dscore: print("Dealer wins!") else: print("It's a tie!")