AnthisCareerAcademy / 2024_AM_21-game

1 stars 8 forks source link

checking if-else statements #10

Closed brodymchenry closed 1 month ago

brodymchenry commented 1 month ago

def check_score(cards): score = 0

# These cards have special point values.
special_cases = ["J", "Q", "K", "A"]

for card in cards:
    # If the card is not a special card (face, ace), add its points.
    if card[:-1] not in special_cases:
        score += int(card)
    else:
        # If the card is an ace, and 11 points can safely be added, then
        # add 11 points.
        if card[:1] == "A" and score + 11 <= 21:
            score += 11
        # If 11 points cannot be added, then add 1 point.
        elif card[:1] == "A" and score + 11 > 21:
            score += 1
        # Otherwise, if it's a face card, add 10 points.
        else:
            score += 10

# Return the score of the cards.
return score
#insert player_score
#insert dealer_score

if player_score == 21: if dealer_score == 21: print(tie) else: print(win) else: print(...)