import random

deck = []
for suit in ('club', 'diamond', 'heart', 'spade'):
    for rank in range(1, 14):
        deck.append({'suit': suit, 'rank': rank})

def take_card(hand):
    hand.append(deck.pop(random.randrange(len(deck))))

player_hand = []
take_card(player_hand)
take_card(player_hand)

dealer_hand = []
take_card(dealer_hand)
take_card(dealer_hand)

def on_key_down(key):
    if key == keys.H:
        take_card(player_hand)

def draw():
    screen.fill((0, 0, 0))

    def get_total(hand):
        total = 0

        for card in hand:
            total += card['rank']

        return total

    output = []

    output.append('Player hand:')
    for card in player_hand:
        output.append('suit: ' + card['suit'] + ', rank: ' + str(card['rank']))
    output.append('Total: ' + str(get_total(player_hand)))

    output.append('')

    output.append('Dealer hand:')
    for card in dealer_hand:
        output.append('suit: ' + card['suit'] + ', rank: ' + str(card['rank']))
    output.append('Total: ' + str(get_total(dealer_hand)))

    screen.draw.text('\n'.join(output), (15, 15))