title: replace string if a condition is satisfied in python
body: <p>I have a file that looks like this,  if docket ="3ghi" (i could be "3ghi" or 5"ghi" )in the file then condition is greater than 4 should be changed to "new" and condition &lt;=2 should be changed to "fair" . I added my code below, the replace command works but my if loop is bad. Please help.</p>
  
  <pre><code>Input:
  &lt;code=report docket="3ghi" parse=20&gt;
      &lt;items="20" product="abc" condition="9"&gt;
      &lt;items="50" product="xyz" condition="8"&gt;
      &lt;items="" product="mno" condition="2"&gt;
  
  Output:
  &lt;code=report docket="3ghi" parse=20&gt;
      &lt;items="20" product="abc" condition="new"&gt;
      &lt;items="50" product="xyz" condition="new"&gt;
      &lt;items="" product="mno" condition="fair"&gt;
  
  with open(("test.txt",'r') as new:
     readin = new.read
     if "docket =3ghi" == True:
          readin.replace('condition="4-100"', 'condition="new"')
          readin.replace('condition="1-2"', 'condition="fair"')
          x.write(readin)
  </code></pre>