示例#1
0
        # initial deal
        for i in range(2):
            player_hand.add_card(deck.deal())
            x = deck.deal()
            dealer_hand.add_card(x)
            if i == 1:
                print(
                    "There are {} cards left in the deck.".format(
                        deck.cards_left()))
                print("The dealer's face-up card is a {}".format(x))
                print("")

                print(
                    "Your hand consists of:{}".format(
                        player_hand.show_cards()))
    print("Your score is: {}".format(player_hand.score()))

    # handling being dealt a blackjack
    if blackjack_test(player, player_hand, dealer_hand) == False:
        hit = 'y'

        # the player gets to hit or stay
        while ((hit != 'n') and (player_hand.score() <= 21)):

            hit = (input("Hit? (y/n)").lower())
            if hit != 'n':
                x = deck.deal()
                player_hand.add_card(x)
                print("You were dealt a {}.".format(x))
                print("Your score is: {}".format(player_hand.score()))