Use an iterative method (i.e. for loop) to determine if a string is a palindrome. Hint: A string in Python is represented as a list with each element being a unique character.
python3 code:-
def palindrome(s):
for i in range(0,int(len(s)/2)):
if s[i] != s[len(s)-i-1]:
return 'not a palindrome'
return 'palindrome'
s=input()
print(palindrome(s))
Get Answers For Free
Most questions answered within 1 hours.