Python program to check if a given string is a palindrome
You can check if a given string is a palindrome by comparing the original string with its reverse. Here's a Python program to do that:
def is_palindrome(string):
# Remove spaces and convert to lowercase for case-insensitive comparison
string = string.replace(" ", "").lower()
# Compare the string with its reverse
return string == string[::-1]
# Example usage:
input_string = input("Enter a string: ")
if is_palindrome(input_string):
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
```
This program prompts the user to input a string, removes spaces and converts it to lowercase, and then checks if the string is equal to its reverse. If they are equal, it prints that the string is a palindrome; otherwise, it prints that the string is not a palindrome.