title: Remove substring only at the end of string
body: <p>I have a bunch of strings, some of them have <code>' rec'</code>. I want to remove that only if those are the last 4 characters.</p>
  
  <p>So in other words I have</p>
  
  <pre><code>somestring = 'this is some string rec'
  </code></pre>
  
  <p>and I want it to become</p>
  
  <pre><code>somestring = 'this is some string'
  </code></pre>
  
  <p>What is the Python way to approach this?</p>