Returning result of palindrome program using while-loop
<pre><code>n = str(input('Enter the string:'))
def palindrome(n):
    index = 0
    check = True
    while index&lt;int(len(n)/2):
        if n[index]==n[-1-index]:
            index+=1
            return True
            break
        return False
if palindrome(n)==True:
    print('palindrome')
else:
    print('not palindrome')
</code></pre>

<p>I am not getting the correct answer for this palindrome program.</p>

<p>The classic solution:</p>

<pre><code>def palindrome(n):
    start = 0
    end = len(n) - 1
    while (start &lt; end):
        if (n[start] != n[end]):
            return False
        start = start + 1
        end = end - 1
    return True
</code></pre>

python