How do I specify the string method count?
<p>I am trying to implement a function that takes a string as a parameter, and whether or not the string contains the letter 'ion' at the end determines the output. </p>

<p>For example, if I input the string 'accordionist', I should then get the output of 'accordionist' because although it contains 'ion', it is not at the end of the string. </p>

<p>However, if I input the string 'congratulation', I want to then change the 'ion' to an 'e' because 'ion' is at the end of the word.</p>

<p>So far I have :</p>

<pre><code>def wordSwap(x):

    if x.count('ion') == 1:
        return x.replace('ion','e')
    else:
        return x
</code></pre>

<p>&nbsp;</p>

<pre><code>&gt;&gt;&gt; wordSwap('congratulation')
'congratulate'
</code></pre>

<p>This works well, but when I use a string such as:</p>

<pre><code>&gt;&gt;&gt; wordSwap('accordionist')
</code></pre>

<p>I get</p>

<pre><code>'accordeist'
</code></pre>

<p>How do I specify that I only want to change the 'ion' to an 'e' only if it is at the end of the string?</p>
