title: How to randomly select an item from a dictionary?
body: <p>I'm a python beginner trying to make a game of blackjack, and have been continuously getting multiple keyerrors regarding this code</p>
  
  <pre><code>def rank(rank):
      rank={
          '2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'10':10,'Jack':10,
         'King':10,'Queen':10,'Ace':1}
      return random.choice(rank)
  </code></pre>
  
  <p>The error occurs when I try calling the function like this</p>
  
  <pre><code>def draw_card(card):
      card_rank=Card.rank(rank)
      card_suit=Card.suit(suit)
      card={card_suit:card_rank}
      return card
  </code></pre>
  
  <p>to try and use the 'rank' function in class 'Card' to apply attributes to a new 'card' variable</p>