curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa9.md
Given an array of playing cards, return a new array with the numeric value of each card.
Card Values:
"A") has a value of 1."2" - "10") have their face value: 2 - 10, respectively."J"), Queen ("Q"), and King ("K") are each worth 10.Suits:
"S"), Clubs ("C"), Diamonds ("D"), or Hearts ("H").Card Format:
"valueSuit". For Example: "AS" is the Ace of Spades, "10H" is the Ten of Hearts, and "QC" is the Queen of Clubs.card_values(["3H", "4D", "5S"]) should return [3, 4, 5].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(card_values(["3H", "4D", "5S"]), [3, 4, 5])`)
}})
card_values(["AS", "10S", "10H", "6D", "7D"]) should return [1, 10, 10, 6, 7].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(card_values(["AS", "10S", "10H", "6D", "7D"]), [1, 10, 10, 6, 7])`)
}})
card_values(["8D", "QS", "2H", "JC", "9C"]) should return [8, 10, 2, 10, 9].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(card_values(["8D", "QS", "2H", "JC", "9C"]), [8, 10, 2, 10, 9])`)
}})
card_values(["AS", "KS"]) should return [1, 10].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(card_values(["AS", "KS"]), [1, 10])`)
}})
card_values(["10H", "JH", "QH", "KH", "AH"]) should return [10, 10, 10, 10, 1].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(card_values(["10H", "JH", "QH", "KH", "AH"]), [10, 10, 10, 10, 1])`)
}})
def card_values(cards):
return cards
def card_values(cards):
values = []
for card in cards:
value_str = card[:-1]
if value_str == "A":
value = 1
elif value_str in ["J", "Q", "K"]:
value = 10
else:
value = int(value_str)
values.append(value)
return values