# Python > Black jack > Task 3: Value of an ace

Hello stars!

Here is my context:

• The function value_of_card(card) works fine;
• I am stuck with the function value_of_ace(card_one, card_two) which I am copyting/pasting below;
• I am getting 2 types of errors:
First type of error: ‘’‘AssertionError: None != 1 : Called value_of_ace(Q, A). The function returned None, but the test expected 1 as the value of an ace card when the hand includes (‘Q’, ‘A’).’‘’
Second type of error: ```AssertionError: 11 != 1 : Called value_of_ace(2, A). The function returned 11, but the test expected 1 as the value of an ace card when the hand includes (‘2’, ‘A’).````

Question: Can you help me finishing this exercise?

``````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.
"""
value_in_hand = value_of_card(card_one) + value_of_card(card_two)
option_1 = value_in_hand + 1
option_11 = value_in_hand + 11

if option_1 <= 21 and option_11 <=21:
# Compare both options
if (21 - option_1) < (21 - option_11):
return 1
else:
return 11
``````

I have tweaked my code to try covering all possible scenarios:

``````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.
"""
value_in_hand = value_of_card(card_one) + value_of_card(card_two)
option_1 = value_in_hand + 1
option_11 = value_in_hand + 11

if (option_11) > 21 and (value_in_hand + 1) > 21:
return 0
elif (option_11) > 21:
return 1
elif (option_1) > 21:
return 11
else:
# Compare both options
if (21 - option_1) < (21 - option_11):
return 1
else:
return 11

``````

But I am still getting the following two errors:

Error #1:

``````AssertionError: 11 != 1 : Called value_of_ace(2, A). The function returned 11, but the test expected 1 as the value of an ace card when the hand includes ('2', 'A').
``````

Error #2:

``````AssertionError: 11 != 1 : Called value_of_ace(A, 2). The function returned 11, but the test expected 1 as the value of an ace card when the hand includes ('A', '2').
``````
1. Do you understand what the test is doing?
2. Do you understand what the test is expecting and why?
3. Do you understand what your code returns and how it differs?
4. Do you understand why your code is returning what it returns?