title: Substituting part of a string starting at a position
body: <p>I'm trying to conditionally update part of a string starting at a specified location. I have something like this:</p>
  
  <pre><code>i = 0
  bre = 'newtext'
  with open(myfile, "r") as f:
      data = f.readlines()
      for line in data:
          if i &gt; 0 and line[98] == '1':
              print 'ok'
              line[1562] = bre
          i += 1
          # write line to a file
  </code></pre>
  
  <p>The error I am receiving is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 19, in &lt;module&gt;
      line[1562] = bre
  </code></pre>