title: Python script to replace a string in a particular line
body: <p>I have a file "xyz.txt" and I am writing a python script to replace a string in a particular line. So essentially I have a string which says
  <code>x ==</code> in one line which I want to replace with <code>x == 10</code>. 
  In another line I have <code>xx == 5</code> which I don't want to replace. </p>
  
  <p>When I use the command -</p>
  
  <pre><code>for line in fileinput.input([filename],inplace=True):
      line.replace(old string, new string) 
  </code></pre>
  
  <p>where, </p>
  
  <pre><code>old string = "x =="
  new string = "x == 5". 
  </code></pre>
  
  <p>This ends up replacing the other line that has <code>xx == 5</code> that I don't want to modify. </p>
  
  <p>What would be the best way to just modify that one particular line with <code>x ==</code>
  rather than modifying all the lines with "x == " string present in them?</p>