how can I replace the nth occurrences in a list of string without using the built in function
<p>I'm kind of new in python and I have problem to write a script which take four element (ex str, Replacefrom, replaceto and n) find the characters and replace the nth occurrence.  </p>

<p>Example:</p>

<pre><code>&gt;&gt;&gt; replaeceit("Mississippi", "s", "l", 2)
'Mislissippi'
&gt;&gt;&gt; replaeceit("Mississippi", "s", "l", 0)
'Mississippi'
</code></pre>

<p>the n is 2 so the code change the second s to l .. and when the n=0 then it dosen't do nything</p>

<p>honestly I don't know how to implement n to the equation this is my code so far without n</p>

<pre><code>def replaceit(str,replacefrom,replaceto):
    new=""
    for letter in str:
        if letter== replacefrom:
            new=new+replaceto
        else: 
            new=new+letter
    return new
</code></pre>
