Q:

Adding components of a list together for BlackJack

I am making a BlackJack game for a project of mine. I made a deck of cards in a list, including ranks and suits, but when I try to add the hand of the player, I have only one value returning, instead of the sum. 
I have no clue how to manage it. First I have to get all the elements of the list and then remove the suit to get a number, but some of my numbers are letters (Jack, queen, king, ace...) and have specific values to them. How can I add those together? I tried with for, while and other things, but in vain. 
Any tips on how to achieve this?
Here's a sample of my code:
def create_deck(): #this creates the deck of cards
    suit_string = 'hdcs'
    rank_string = '23456789TJQKA'
    global deck
    deck = []
    for suit in range(4):
        for suit in range(13):
            cards = rank_string[rank] + suit_string[suit]
            deck.append(cards)
            random.shuffle(deck)
    return deck

def deal_cards(): #This takes one card from the deck and gives it to the player
    return deck.pop(0)

def hand(): #Initial two cards
    global player1_hand
    player1_hand = []
    print "Player's hand:"
    for i in range(2): #initial cards
        player1_hand.append(deal_cards())
    print player1_hand
    print value()   

def value():
    i = 0
    while i < len(player1_hand):
        card = player1_hand[i]
        value = card[i]
        if value in ('T','J','Q','K'):
            return 10
        elif value == 'A':
            print "Please choose between 1 and 11."
            value_a = input("---> ")
            return value_a
        else:
            return value
    i += 1

Now this is what it gives me:
Player's hand:
['Ks','Th']
Value 10

I know I didn't really add the values together, but I have no idea how to manage it. 
Any help would be appreciated.
Hope I was clear enough, as English isn't my main language.

A:

By using a dict of "rank values" you can just loop through the player's hand and total up the values.
def value():
    hand_total = 0
    # Add in a dict of "rank values" (excluding the Ace)
    rank_values = {'2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8,
                   '9':9, '10':10, 'J':10, 'Q':10, 'K':10}
    # No need for the while loop 
    for i in xrange(len(player1_hand)):
        card = player1_hand[i][0] # the added index will get the card          
        if card == 'A':          # without the suit.
            print "Please choose between 1 and 11."
            value_a = input("---> ")
            hand_total += int(value_a) # add a type check before this
        else:
            hand_total += rank_values[card]
    return hand_total

Using the dict you won't have to distinguish between face cards or numbered cards, just use the keys(cards) value and total the amount.

