I am working on a simple Blackjack game.
deck = ['Ace',2,3,4,5,6,7,8,9,10,'Jack','Queen','King']
card_1 = random.choice(deck)
card_2 = random.choice(deck)
def my_hand(card_1,card_2):
total = card_1 + card_2
if total > 21:
return "Bust!"
elif total == 21:
return "Blackjack!"
elif total < 21:
return "Hit again?"
print card_1,'and',card_2
my_hand(card_1,card_2)
How do I assign specific items in the list an integer value? Namely, I'd like to assign 'Ace' to the integer 1 or 11, and 'Jack', 'King', and 'Queen' equal to 10.
Thank you.
Use a dictionary (and I suggest that you convert all keys to strings):