import random deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] * 4 random.shuffle(deck) def deal_card(): return deck.pop() def d(hand): total, ace_count = sum(hand), hand.count(1) for _ in range(ace_count): if total + 10 <= 21: ace_value = input("You have an Ace! Choose 1 or 11: ") while ace_value not in ['1', '11']: ace_value = input("Invalid input. Choose 1 or 11: ") total += 10 if ace_value == '11' else 0 return total def play_game(): player_hand, dealer_hand = [deal_card(), deal_card()], [deal_card(), deal_card()] while d(player_hand) < 21: print(f"Your hand: {player_hand}, total: {d(player_hand)}") action = input("Hit or Stand? (h/s): ").lower() if action == 'h': player_hand.append(deal_card()) elif action == 's': break player_total = d(player_hand) while d(dealer_hand) < 17: dealer_hand.append(deal_card()) dealer_total = d(dealer_hand) print(f"Your hand: {player_hand}, total: {player_total}") print(f"Dealer's hand: {dealer_hand}, total: {dealer_total}") if player_total > 21: print("You bust! Dealer wins.") elif dealer_total > 21 or player_total > dealer_total: print("You win!") elif player_total < dealer_total: print("Dealer wins!") else: print("It's a draw!") if __name__ == "__main__": play_game() #with chat gpt but got it to explane each part