In: Computer Science
python question
A word is a palindrome if it the same read forwards and backwards. We will call a word a fuzzy palindrome if it is the same read forwards and backwards, except for possible differences in case. For example, both 'tattarrattat' and 'TaTtArRAttat' are fuzzy palindromes. Define a function is_fuzzy_palindrome that returns True if and only if its argument is a fuzzy palindrome. This method may be useful: S.lower() -> str : Return a copy of the string S converted to lowercase.
Python code:
#defining is_fuzzy_palindrome function
def is_fuzzy_palindrome(S):
#returning True if the string S and its reverse value converted to
lower case is same else False
return S.lower()==S[::-1].lower()
#calling is_fuzzy_palindrome function and printing result for a
sample value
print(is_fuzzy_palindrome("TaTtArRAttat"))
#calling is_fuzzy_palindrome function and printing result for a
sample value
print(is_fuzzy_palindrome("tattarrattat"))
#calling is_fuzzy_palindrome function and printing result for a
sample value
print(is_fuzzy_palindrome("hi"))
Screenshot:
Output: