Suppose we have a string s; we have to check whether it is a palindrome or not. As we know a palindrome is when the word is the same forwards and backwards.
So, if the input is like s = "racecar", then the output will be True
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
class Solution: def solve(self, s): t=s[::-1] if t==s: return True else : return False ob = Solution() print(ob.solve("racecar"))