Python - Replace only exact word in string : <p>I want to replace only specific word in one string. However, some other words have that word inside but I don't want them to be changed.</p>

<p>For example, for the below string I only want to replace <code>x</code> with <code>y</code> in <code>z</code> string. how to do that?</p>

<pre><code>x = "the"
y = "a"
z = "This is the thermometer"
</code></pre>
