title: Python generate random steps for range function in each iteration of a for loop
body: <p>I am trying to split a string into small chunks of random sizes. For example,</p>
  
  <p><code>string = 'qwertyuiopp'</code> into <code>['qw','e','rty,'u','iopp']</code></p>
  
  <pre><code>for record in SeqIO.parse(args.fasta_file , "fasta"):
      step = 200
      for i in range(0, len(record),step):
          oline = "&gt;"+record.id+"_"+str(i+1)+"\n"
          ofname.write(oline)
          step = random.randrange(200,2000)
          if len(record.seq[i:i+step]) &gt;= 200:
              oline= str(record.seq[i:i+step])+"\n"
              ofname.write(oline)
          i=i+step
          else:
              oline= str(record.seq[i-200:])+"\n"
              ofname.write(oline)
          i=len(record)+1
  </code></pre>
  
  <p>I figure the problem is that the step in range function remains constant(200) inspite of modifying the value of step using randrange. but I dont know how I should go about this. Thank for any help.</p>