title: Select 50 items from list at random
body: <p>I have a function which reads a list of items from a file. How can I select only 50 items from the list randomly to write to another file?</p>
  <pre><code>def randomizer(input, output='random.txt'):
      query = open(input).read().split()
      out_file = open(output, 'w')
      
      random.shuffle(query)
      
      for item in query:
          out_file.write(item + '\n')   
  </code></pre>
  <p>For example, if the total randomization file was</p>
  <pre><code>random_total = ['9', '2', '3', '1', '5', '6', '8', '7', '0', '4']
  </code></pre>
  <p>and I would want a random set of 3, the result could be</p>
  <pre><code>random = ['9', '2', '3']
  </code></pre>
  <p>How can I select 50 from the list that I randomized?</p>
  <p>Even better, how could I select 50 at random from the original list?</p>