title: A function it Python that replaces strings
body: <p>I need to write a function, <code>replaceSegment</code>, which takes a string, <code>str</code>, and another string, <code>replace</code>, and two integers, <code>start</code> and <code>stop</code>.</p>
  
  <p>The function should return a new string in which all occurrences of <code>'X'</code> in <code>str</code>, ranging from index <code>start</code> up to, but not including, the index <code>stop</code> are replaced with <code>replace</code>.</p>
  
  <p>Built-in functions or modules that perform the same or similar information may not be used in this task. </p>
  
  <p><strong>Example:</strong>  </p>
  
  <pre><code>replaceSegment ("HXello! X balXoo!", "Hope", 3, 7) 'HXello! Hope balXoo!
  </code></pre>
  
  <p>It's from an old exam and I can't figure it out. I guess that it should use a for loop?</p>