I have written a palindrome program. And I was just wondering if it correct? I checked using the words racecar and madam, and it says they are palindromes. I have also tested nonpalindrome words and it worked correctly.
Is my implementation correct? If it's not could you correct it for me. It it works correct, is there an easier way to implement this?
def is_palindrome(x):
for i in range(0,len(x)):
x = x.lower()
if x[i::1] == x[::-1]:
return("%s Is a palindrome" %(x))
else:
return("%s Is not a palindrome" %(x))
print(is_palindrome('racecar'))
Here is my palindrome program I was just wondering is it right? I checked using the words racecar and madam and it says they are palindrome and I tested nonpalindrome words and it worked. Can someone tell me if it is wrong and then correct me on my mistakes or If its right but there is an easier way can you show me?