For function value_of_ace, the accurate instruction for A in hand is to return 1. Otherwise the tests fail. The instructions actually say 1, but the doc string says different.
Welcome to the Exercism forums! ![]()
Thanks for starting this thread. I am a little confused however. The docstring for the solution file has this as it’s note:
"""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.
"""
And the directions read (emphasis mine):
3. Calculate the value of an ace
As mentioned before, an ace can be worth either 1 or 11 points. Players try to get as close as possible to a score of 21, without going over 21 (going “bust”).
Define the value_of_ace(<card_one>, <card_two>) function with parameters card_one and card_two, which are a pair of cards already in the hand before getting an ace card. Your function will have to decide if the upcoming ace will get a value of 1 or a value of 11, and return that value. Remember: the value of the hand with the ace needs to be as high as possible without going over 21.
Hint: if we already have an ace in hand, then the value for the upcoming ace would be 1.
>>> value_of_ace('6', 'K')
1
>>> value_of_ace('7', '3')
11
So the docstring seems accurate for a hand that starts with an Ace in it. In that scenario, the upcoming Ace would have a value of 1.
Would it be clearer this way?:
"""Calculate the most advantageous value for the upcoming 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 the existing hand)
3. '2' - '10' = numerical value.
"""
Hi Bethany! Thanks for your time and reply. I was actually confused myself and took it far. It’s all clear now, no changes required.
Hi @roxanacrisan,
No worries at all! It is a bit confusing (we’ve had issues in the past). I am going to write a note to myself to re-read everything again after a pause, and maybe change the docstring to the one I proposed.
Thanks again for starting a discussion. ![]()