How to check a string is palindrome in python
# Remove spaces and convert the string to lowercase
input_string = input_string.replace(" ", "").lower()
# Compare the string with its reverse
if input_string == input_string[::-1]:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
No comments