I have no idea about what is wrong with my code, tried thousands of times, but it is showing error every time.
My code:
def value_of_card(card):
“”"Determine the scoring value of a card.
:param card: str - given card.
:return: int - value of a given card. See below for values.
1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
2. 'A' (ace card) = 1
3. '2' - '10' = numerical value.
"""
face_cards = ('J', 'Q','K')
if card in face_cards:
return 10
if card == 'A':
return 1
else:
return int(card)
def higher_card(card_one, card_two):
“”"Determine which card has a higher value in the hand.
:param card_one, card_two: str - cards dealt in hand. See below for values.
:return: str or tuple - resulting Tuple contains both cards if they are of equal value.
1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
2. 'A' (ace card) = 1
3. '2' - '10' = numerical value.
"""
card1 = value_of_card(card_one)
card2 = value_of_card(card_two)
if card1>card2:
return card_one
if card2>card1:
return card_two
else:
return card_one,card_two
def value_of_ace(card_one, card_two):
“”"Calculate the most advantageous value for the ace card.
:param card_one, card_two: str - card dealt. See below for values.
:return: int - either 1 or 11 value of the upcoming ace card.
1. 'J', 'Q', or 'K' (otherwise known as "face cards") = 10
2. 'A' (ace card) = 11 (if already in hand)
3. '2' - '10' = numerical value.
"""
total = value_of_card(card_one) + value_of_card(card_two)
if 'A' in (card_one, card_two) and total < 11:
return 11
else:
return 1
The error:
CODE RUN
test_data = [('2', '3', 11), ('3', '6', 11), ('5', '2', 11),
('8', '2', 11), ('5', '5', 11), ('Q', 'A', 1),
('10', '2', 1), ('7', '8', 1), ('J', '9', 1),
('K', 'K', 1), ('2', 'A', 1), ('A', '2', 1)]
TEST FAILURE
One or more variations of this test failed. Details can be found under each [variant#].
Can anyone help me?
(I'm sorry if it shouldn't be posted here, it's my first time posting)