Python Practice › String Programs › Program 25
Check a palindrome string
Check whether a given string is a palindrome.
Input
"sqatoolssqatools", "racecar"
Output
sqatoolssqatools is not a palindrome racecar is a palindrome
Approach
- Compare the string with its reverse.
Solution
for s in ["sqatoolssqatools", "racecar"]: print(s, "is a palindrome" if s == s[::-1] else "is not a palindrome")Output
sqatoolssqatools is not a palindrome racecar is a palindrome
Learn the concept
New to this topic? Read the lesson, then come back.