Replacing letter in string by index
<p><strong>Edit: this is not an exact duplicate of the other question: here I want to know how to replace letters at certain indexes. But as it is answered, I don't care that it is closed.</strong></p>

<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9189172/python-string-replace">python string replace</a>  </p>
</blockquote>



<p>This simple code that simply tries to replace semicolons (at i-specified postions) by colons does not work:</p>

<pre><code>for i in range(0,len(line)):
     if (line[i]==";" and i in rightindexarray):
         line[i]=":"
</code></pre>

<p>It gives the error </p>

<pre><code> line[i]=":"
TypeError: 'str' object does not support item assignment
</code></pre>

<p>How can I work around this to replace the semicolons by colons? Using replace does not work as that function takes no index- there might be some semicolons I do not want to replace.</p>

<p><strong>Example</strong></p>

<p>In the string I might have any number of semicolons, eg "Hei der! ; Hello there ;!;"</p>

<p>I know which ones I want to replace (I have their index in the string). Using replace does not work as I'm not able to use an index with it.</p>
