只需反转字符串并将其与原始字符串进行比较
string_to_check = input("Enter a string")if string_to_check == string_to_check[::-1]: print("This is a palindrome")else: print("This is not a palindrome")
只需反转字符串并将其与原始字符串进行比较
string_to_check = input("Enter a string")if string_to_check == string_to_check[::-1]: print("This is a palindrome")else: print("This is not a palindrome")