Input: malayalam
Output: Yes
Input: geeks
Output: No
Method #1
- Find reverse of string
- Check if reverse and original are same or not.
# function which return reverse of a string
def isPalindrome(s):
return s == s[::-1]
# Driver code
s = "malayalam"
ans = isPalindrome(s)
if ans:
print("Yes")
else:
print("No")
Output :
Yes