At Grammarly, you need a utility function that checks whether a given string reads the same forward and backward. Write a function that returns True if the input string is a palindrome and False otherwise.
sTrue if s is identical when reversedFalse otherwiseA palindrome comparison in this problem is case-sensitive and includes all characters exactly as they appear.
Example 1
Input: s = "racecar"
Output: True
Explanation: The string is the same from left to right and right to left.
Example 2
Input: s = "hello"
Output: False
Explanation: Reversing the string gives "olleh", which is different from "hello".
Example 3
Input: s = "abba"
Output: True
Explanation: Matching characters appear symmetrically from both ends.
0 <= len(s) <= 10^5s may contain letters, digits, spaces, or symbolss = "racecar"OutputTrueWhyEach character matches its symmetric counterpart: `r-r`, `a-a`, `c-c`, with `e` in the middle.s = "hello"OutputFalseWhyThe first and last characters do not match, so the string is not a palindrome.s = "abba"OutputTrueWhyThe pairs `a-a` and `b-b` match, so the string reads the same in both directions.0 <= len(s) <= 10^5s may contain letters, digits, spaces, or symbolsComparison is case-sensitiveAll characters are compared exactly as givendef is_palindrome(s):