# Blackjack excersice

``````if card == "J" or card == "Q" or card == "K":
return 10
elif card == "A":
return 1
``````

I saw in the solution part that I have to write one more “return” at the end of the first task, but I don’t understand why.
I would appreciate if someone help me find out the reason.

1. When sharing code, more is usually better. This looks like a snippet, not a full function. You should (almost) always share the full function.
2. Your function needs to handle cards like `"2", "6", "9"`. This code doesn’t handle those inputs.

yes, you’re right. This the full function:

def value_of_card(card):
if card == “J” or card == “Q” or card == “K”:
return 10
elif card == “A”:
return 1

another thing that I don’t understand and I think it’s because I don’t know how to play blackjack is that aren’t the cards just letters like J Q K A? Why should a number be a possible input?
p.s: don’t why the indentations can not be shown when I write the full function.

The `card` represents the face of a playing card. A standard deck of playing cards has cards `A 2 3 4 5 6 7 8 9 10 J Q K`. You need to be able to handle any/all of these values.

Because you didn’t wrap it in a “code block”.

1 Like

Thanks a million.

``````def value_of_card(card):
if card == "J" or card == "Q" or card == "K":
return 10
elif card == "A":
return 1
else:
return int(card)
``````

it still doesn’t work, as u said I handled the else part, but idk why it’s not working again.
I don’t know how to deal with the problems with my code :(
I don’t want to check the solutions either.

That looks like it ought to work. What about it doesn’t work? Are there failing tests? What do they say?

It worked finally

1 Like