In & General Intuition's mobile surfaces, lightweight input validation may need to detect whether a text string reads the same forward and backward. Write a function that returns whether a given string is a palindrome.
A palindrome is a string that is identical when reversed. For this problem, compare characters exactly as they appear: case, spaces, punctuation, and digits all matter.
sTrue if s is a palindromeFalse otherwiseExample 1
Input: s = "racecar"
Output: True
"racecar" reads the same from left to right and right to left.
Example 2
Input: s = "hello"
Output: False
The reversed string is "olleh", which does not match the original.
Example 3
Input: s = "a b a"
Output: True
Spaces are part of the string, and this exact sequence is symmetric.
0 <= len(s) <= 10^5s may contain lowercase letters, uppercase letters, digits, spaces, and punctuations = "racecar"OutputTrueWhyThe characters match symmetrically from both ends: `r-r`, `a-a`, `c-c`, with `e` in the middle.s = "hello"OutputFalseWhyThe first and last characters are `h` and `o`, which do not match.s = "abba"OutputTrueWhyBoth outer and inner character pairs match, so the string is a palindrome.0 <= len(s) <= 10^5s may contain letters, digits, spaces, and punctuationComparison is case-sensitiveDo not remove or ignore any charactersdef is_palindrome(s):