Have a look at the below code, which will check whether a word is palindrome or not.
str = input("Enter the string")
l = len(str)
p = l-1
index = 0
while index < p:
if str[index] == str[p]:
index = index + 1
p = p-1
print("String is a palindrome")
break
else:
print("string is not a palindrome")
On the off chance that a word is inputted, for instance, I need the program to check whether this word is a palindrome and give yield as "The given word is a palindrome".
However, I'm confronting a difficulty that, the program checks first r and r and prints "The given word is a palindrome" and afterward checks o and o and prints "The given word is a palindrome". It prints the outcome the same number of times as it is checking the word.
I need the outcome to be conveyed just a single time. How to change the code?