title: How to limit the number of times a specific random number is generated python
body: <p>I am currently working on a memory game in python as a class project. I am trying to generate random numbers between 0 and 3 which would correspond to a certain card. The thing is, I need each card to only appear twice. No more, and no less. </p>
  
  <p>Here is my current code:</p>
  
  <pre><code>import random
  cards = ["___TI___", "___GK___", "___QW___", "___KJ___"]
  boardTemp1 = ['1', '2',
                '3', '4',
                '5', '6',
                '7', '8']
  
  def shuffle():
  
      cardChoose = random.randint(0, 3)
      boardChoose = random.randint(0, 7)
      randCard = 9
      randCard = cards[cardChoose]
      boardTemp1[boardChoose] = cards[cardChoose]
      return randCard
  
  boardTemp1[0] = shuffle()
  boardTemp1[1] = shuffle()
  boardTemp1[2] = shuffle()
  boardTemp1[3] = shuffle()
  boardTemp1[4] = shuffle()
  boardTemp1[5] = shuffle()
  boardTemp1[6] = shuffle()
  boardTemp1[7] = shuffle()
  
  
  print(boardTemp1)
  </code></pre>
  
  <p>Thanks for any help</p>