title: How to replace a word in a sentence without using the python replace method
body: <p>i have written a function to replace a word in a sentence without using the python built in replace method, the issue is that my code fails in edge cases were the word combines with another, am suppose to replace every occurrence of maybe with perhaps. Take a look at my code</p>
  
  <pre><code>def replace_all (target,find,replace):
                  split_target = target.split()
                  result = ''
                  for i in split_target:
                          if i == find:
                                  i = replace
                          result += i + ' '
                  return result.strip()
              target = "Maybe she's born with it. Maybe it's Maybeline."
              find = "Maybe"
              replace = "Perhaps"
              print replace_all(target, find, replace)
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>Perhaps she's born with it. Perhaps it's Maybeline.
  </code></pre>
  
  <p>But am expecting it to print this:</p>
  
  <pre><code>Perhaps she's born with it. Perhaps it's perhapsline. 
  </code></pre>
  
  <p>Notice the last word which is maybeline is suppose to change to perhapsline. I have battled with this for a week now, any help will be appreciated.</p>