samedi 16 mai 2020

How to get value of key in Python Blackjack game

I just started a blackjack game project. So far, i've created cards and hand creator funtion. As you can see from my code down below, i pick my hand through pick() function and i get the keys of the rank dictionary.

rank={'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'10':10,'J':10,
   'K':10,'Q':10,'A':1}
your_hand=[]
opponent_hand=[]
def pick():    
    your_hand =  random.sample(list(rank),2) 
    opponent_hand = random.sample(list(rank),2) 
    print(your_hand[values])
    print(opponent_hand)
def count():
    pass

I was wondering is this code getting their values and if not, how can i get their values? Also is this a good approach for coding a blackjack game.




Aucun commentaire:

Enregistrer un commentaire