title: How to make a random but partial shuffle in Python?
body: <p>Instead of a complete <code>shuffle</code>, I am looking for a <strong>partial</strong> <code>shuffle</code> function in python.</p>
  
  <p><strong>Example :</strong> "string" must give rise to "stnrig", but not "nrsgit"</p>
  
  <p>It would be better if I can define a specific "percentage" of characters that have to be rearranged. </p>
  
  <p>Purpose is to test string comparison algorithms. I want to determine the "percentage of shuffle" beyond which an(my) algorithm will mark two (shuffled) strings as completely different.</p>
  
  <p><strong>Update :</strong></p>
  
  <p>Here is my code. Improvements are welcome ! </p>
  
  <pre><code>import random
  
  percent_to_shuffle = int(raw_input("Give the percent value to shuffle : "))
  to_shuffle = list(raw_input("Give the string to be shuffled : "))
  
  num_of_chars_to_shuffle = int((len(to_shuffle)*percent_to_shuffle)/100)
  
  for i in range(0,num_of_chars_to_shuffle):
      x=random.randint(0,(len(to_shuffle)-1))
      y=random.randint(0,(len(to_shuffle)-1))
      z=to_shuffle[x]
      to_shuffle[x]=to_shuffle[y]
      to_shuffle[y]=z
  
  print ''.join(to_shuffle)
  </code></pre>