import random


class Hand:
    """
    Class of the player's hand
    """
    def __init__(self, name):
        self.name = name
        self.cards = []

    def add_card(self, card: int) -> None:
        """
        Method of adding cards to hand
        :param card: str
        :return: None
        """
        self.cards.append(card)

    def get_value(self) -> int:
        """
        Method of determining value
        :return: int
        """
        result = 0
        aces = 0

        for i_card in self.cards:
            if i_card == 'A':
                aces += 1
                if result + aces * 11 <= 21:
                    result += aces * 11
                else:
                    result += 1
            else:
                result += i_card

        return result


class Deck:
    """
    Class, that takes and mixes card deck
    """
    def __init__(self) -> None:
        self.cards = [i_card for i_card in range(2, 11)] * 4
        self.cards += 'A A A A'.split()
        random.shuffle(self.cards)

    def deal_card(self) -> int:
        """
        Method that takes one card from the deck
        :return: str
        """
        return self.cards.pop()


def new_game():
    deck = Deck()
    player_hand = Hand('Player')
    dealer_hand = Hand('Dealer')
    player_hand.add_card(deck.deal_card())
    player_hand.add_card(deck.deal_card())

    dealer_hand.add_card(deck.deal_card())
    dealer_hand.add_card(deck.deal_card())

    print(f'Your cards: {player_hand.cards}.')
    print(f'Dealers cards: {dealer_hand.cards}.')

    in_game = True

    while True:
        if player_hand.get_value() < 21:
            ans = input('Take a card? yes / no ')
            if ans.lower() == 'yes':
                player_hand.add_card(deck.deal_card())
                print(f'Your cards: {player_hand.cards}.')
            else:
                break

        elif player_hand.get_value() > 21:
            print(f'{player_hand.name} loses.')
            in_game = False
            break
        else:
            print(f'{player_hand.name} wins.')
            in_game = False
            break

    if in_game:

        while dealer_hand.get_value() < 17:
            dealer_hand.add_card(deck.deal_card())
            if dealer_hand.get_value() > 21:
                print(f'{dealer_hand.name} loses.')
                in_game = False

    if in_game:

        if player_hand.get_value() == dealer_hand.get_value():
            print('Draw.')

        elif player_hand.get_value() > dealer_hand.get_value():
            print(f'{player_hand.name} wins.')
        else:
            print(f'{dealer_hand.name} wins. He has {dealer_hand.get_value()} points.')


new_game()

import random


class Hand:
    """
    Class of the player's hand
    """
    def __init__(self, name):
        self.name = name
        self.cards = []

    def add_card(self, card: int) -> None:
        """
        Method of adding cards to hand
        :param card: str
        :return: None
        """
        self.cards.append(card)

    def get_value(self) -> int:
        """
        Method of determining value
        :return: int
        """
        result = 0
        aces = 0

        for i_card in self.cards:
            if i_card == 'A':
                aces += 1
                if result + aces * 11 <= 21:
                    result += aces * 11
                else:
                    result += 1
            else:
                result += i_card

        return result


class Deck:
    """
    Class, that takes and mixes card deck
    """
    def __init__(self) -> None:
        self.cards = [i_card for i_card in range(2, 11)] * 4
        self.cards += 'A A A A'.split()
        random.shuffle(self.cards)

    def deal_card(self) -> int:
        """
        Method that takes one card from the deck
        :return: str
        """
        return self.cards.pop()


def new_game():
    deck = Deck()
    player_hand = Hand('Player')
    dealer_hand = Hand('Dealer')
    player_hand.add_card(deck.deal_card())
    player_hand.add_card(deck.deal_card())

    dealer_hand.add_card(deck.deal_card())
    dealer_hand.add_card(deck.deal_card())

    print(f'Your cards: {player_hand.cards}.')
    print(f'Dealers cards: {dealer_hand.cards}.')

    in_game = True

    while True:
        if player_hand.get_value() < 21:
            ans = input('Take a card? yes / no ')
            if ans.lower() == 'yes':
                player_hand.add_card(deck.deal_card())
                print(f'Your cards: {player_hand.cards}.')
            else:
                break

        elif player_hand.get_value() > 21:
            print(f'{player_hand.name} loses.')
            in_game = False
            break
        else:
            print(f'{player_hand.name} wins.')
            in_game = False
            break

    if in_game:

        while dealer_hand.get_value() < 17:
            dealer_hand.add_card(deck.deal_card())
            if dealer_hand.get_value() > 21:
                print(f'{dealer_hand.name} loses.')
                in_game = False

    if in_game:

        if player_hand.get_value() == dealer_hand.get_value():
            print('Draw.')

        elif player_hand.get_value() > dealer_hand.get_value():
            print(f'{player_hand.name} wins.')
        else:
            print(f'{dealer_hand.name} wins. He has {dealer_hand.get_value()} points.')


new_game()

Class of the player's hand Method of adding cards to hand
         :param card: str
         :return: None Method of determining value
         :return: int Class, that takes and mixes card deck Method that takes one card from the deck
         :return: str