def deal_cards(deck, how_many):
    """
    Function used to deal certain number of cards.
    :param deck: list with deck of cards from which cards will be dealt
    :param how_many: number of cards to deal
    :return: list with dealt cards, list with deck, number of dealt cards
    """
    cards = []

    if len(deck) >= how_many:
        for _ in range(how_many):
            cards.append(deck.pop())
        cards_dealt = how_many

    else:
        cards_dealt = len(deck)
        for _ in range(len(deck)):
            cards.append(deck.pop())

    return cards, deck, cards_dealt