title: Generating 'random' string from a different string in python?
body: <p>I'm trying to generate a random string using the elements of a different string, with the same length. </p>
  
  <p>Ex) String: AGAACGC</p>
  
  <p>I want a random string using only elements from the string above</p>
  
  <p>Right now I have:</p>
  
  <pre><code>import random
  seq = 'AGAACGC'
  length = len(seq)    
  
  for blah in range(len(seq)): #Apologies for the lame variable names
      x = random.randint(0,length - 1)
      print seq[x]
  </code></pre>
  
  <p>And of course this will give me something like:</p>
  
  <p>A</p>
  
  <p>A</p>
  
  <p>G</p>
  
  <p>A</p>
  
  <p>C</p>
  
  <p>A</p>
  
  <p>A</p>
  
  <p>How would I alter the program so that it prints out my random string on one line?</p>
  
  <p>I'm hoping for a relatively simple answer, as I'm still a beginner in python, so I don't want to get too fancy. But any help at all would be appreciated.</p>
  
  <p>And is there a way to repeat the randomization 'n' number of times? </p>
  
  <p>Say instead of 1 random string, I wanted 4 random strings on different lines. Is there an easy way doing this? (My newbish mind is telling me to repeat the loop 'n' times...but it needs to be a changeable number of randomized strings)</p>
  
  <p>Sorry for asking. I'd really appreciate some help. I'm stuck on a bigger problem because I don't know how to do these steps.</p>