how do i replace a character in a string by range?
<p>For example:</p>

<pre><code>url = 'www.google.com/bla.bla'
</code></pre>

<p>I need to replace '.' with '' in the last 7 characters 
==> 'www.google.com/blabla'</p>

<p>I have tried :</p>

<pre><code>for i in range(15,22):
   if url[i]=='.':
       url = url.replace('.', "")
</code></pre>

<p>But i get this error:</p>

<blockquote>
  <p>IndexError: string index out of range</p>
</blockquote>

<p>A more <em>generic approach</em> would be to <em>split</em> the URL, replace the dot and then <em>join</em>:</p>

<pre><code>In [1]: url = 'www.google.com/bla.bla'

In [2]: s = url.split("/")

In [3]: s[1] = s[1].replace(".", "")

In [4]: "/".join(s)
Out[4]: 'www.google.com/blabla'
</code></pre>

python string