def _score_hand(hand):
    """Calculates the total score of all cards in the list.
    Only one ace can have the value 11, and this will be reduced
    to 1 if the hand would bust."""

    score = 0
    ace = False

    for next_card in hand:

        # get the value of the card
        card_value = next_card[0]

        # if it is an ace and we do not hold one, the value is 11 instead of 1
        if card_value == 1 and not ace:
            ace = True
            card_value = 11

        # add up the value to the score
        score += card_value

        # if we would bust, check if there is an ace and substract
        # 10 from the value (11 - 1). Also, set the ace variable to False.
        if score > 21 and ace:
            score -= 10
            ace = False

    return score