title: python move characters based on string position
body: <p>I am trying to move a special character from one position to another in a string. I want it to appear after the next character.  Here is my string:</p>
  
  <pre><code>"th i s. i s. a. n i c ^ e . s t r i ng."
  </code></pre>
  
  <p>This symbol can appear at any point.  I have been able to identify the next space but I still can't move it.  </p>
  
  <p>What I have done so far is this:</p>
  
  <pre><code>x= "th i s. i s. a. n i c ^ e . s t r i ng."
  for i in range(len(x)):
      if x[i] == '^':
          j = i + 1
          if x[j] == ' ':
              j = j + 1
              while j &lt; len(x) and x[j] != ' ':
                  j = j + 1
  
              print "in the position " + str(i) + ", I found a hat: '" + str(x[i]) + "'"
              print "in the position " + str(j) + ", I found the next space: '" + str(x[j]) + "'"
              x.remove(i)
              x.insert('^', j)
          else:
              print 'somebody help!'
  </code></pre>