write a python program that takes a string as input and prints whether this string is a…
- User
write a python program that takes a string as input and prints whether this string is a true palindrome or not. A true palindrome is a string such that if you remove all characters except for letters (uppercase and lowercase), the string is equal if read from left to right and from right to left. If the inputted string is a true palindrome, the message YES is displayed else NO is displayed. Only use input() to get input from the console
- Assistant
To determine whether a given string is a true palindrome by removing all non-letter characters and verifying if the remaining characters read the same forwards and backwards, you can use the following Python program:
pythondef is_true_palindrome(s): # Filter the string to include only letters and convert them to lower case filtered_string = ''.join(ch for ch in s if ch.isalpha()).lower() # Check if the filtered string is equal to its reverse return filtered_string == filtered_string[::-1] # Get input from the user input_string = input("Enter a string: ") # Check if the input string is a true palindrome and print the appropriate message if is_true_palindrome(input_string): print("YES") else: print("NO")