Spaces:
Sleeping
Sleeping
Added docstring for card_value
Browse files
app.py
CHANGED
@@ -19,6 +19,17 @@ def blackjack_strategy(player_cards: list[str], dealer_card:str)-> str:
|
|
19 |
Returns: Recommended action ("Hit", "Stand", or "Double Down").
|
20 |
"""
|
21 |
def card_value(card: str) -> int:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
if card[0] == 'A': return 11
|
23 |
elif card[0] in 'KQJ': return 10
|
24 |
else: return int(card[:-1])
|
|
|
19 |
Returns: Recommended action ("Hit", "Stand", or "Double Down").
|
20 |
"""
|
21 |
def card_value(card: str) -> int:
|
22 |
+
"""Converts a card string into its numeric value for Blackjack.
|
23 |
+
Args:
|
24 |
+
card: A string representing a playing card, where the first part is the rank
|
25 |
+
(2-10, J, Q, K, A) and the last character is the suit (H, D, C, S).
|
26 |
+
|
27 |
+
Returns:
|
28 |
+
int: The numeric value of the card:
|
29 |
+
- A (Ace): 11
|
30 |
+
- J, Q, K (Face cards): 10
|
31 |
+
- Numeric cards: Their respective integer value
|
32 |
+
"""
|
33 |
if card[0] == 'A': return 11
|
34 |
elif card[0] in 'KQJ': return 10
|
35 |
else: return int(card[:-1])
|