title: Shuffle only the last element of a list
body: <p>I'm writing a poker engine that draws from a large number of decks and creates many hands. I wanted to make each hand contain only unique cards, so I implemented a duplication check when creating hands:</p>
  
  <pre><code>def draw(self, c):
          """Generate a hand of c cards"""
          y = 0
          while y &lt; c:
              if self.cards[-1] not in drawcards.values():
                  drawcards[y] = self.cards.pop()
                  y += 1
              else:
                  random.shuffle(self.cards)
  
          return drawcards
  </code></pre>
  
  <p>This works perfectly, except for the fact that having to <code>random.shuffle(self.cards)</code> (which is often extremely large) repeatedly has significantly slowed down my hand output.</p>
  
  <p>Is there a way to shuffle only the final element of my <code>cards</code> list without using <code>copy()</code> (that would also be taxing on memory)?</p>
  
  <p>(drawcards is predefined as an empty dictionary)</p>