How to capitalize first and last letters of line in a Python string?
<pre><code>word = input()

word= word.lower()

line = 'ilovecat'

for i in range(0, len(line)):

        if word[0] == line[i]:

            line1 = line[i:]
            line2 = line[:i-2]
            aline = line1+line2
            aline = aline.capitalize()
            print(aline)
        else:
            continue
</code></pre>

<p>The input is "CUTE".<br>
I want to make the output like "CatilovE" but my code prints "Catilove".<br>
I already tried <code>aline.upper(i-2)</code> in this way and of course it didn't work.<br>
What should I do?</p>