Python Problem Solve
Abdullah Shayed
🔍 Palindrome Checker
📝 Check if a string reads the same forward & backward
What in Palindrome ?
A palindrome is a word that reads the same forward and backward.
For Example →
"NaN" →"NaN" Palindrome ✅
"racecar" →"racecar" Palindrome ✅
"rotator" →"rotator" Palindrome ✅
"None" →"Enon" Not Palindrome ❌
"Hello" →"Olleh" Not Palindrome ❌
Let Break Down The problem →
Reverse the given string.
Compare the reversed string with the original string.
Abdullah Shayed
If they are the same → it’s a palindrome.
Otherwise → not a palindrome.
Step-by-Step Solution →
Take input from the user.
Initialize an empty string backwardStr.
Reverse the string using a while loop.
Compare the original string and the reversed string.
Print the result based on the comparison.
Input: NaN
Output: NaN is a Palindrome Word
Abdullah Shayed
Input: racecar
Output: racecar is a Palindrome Word
Input: rotator
Output: rotator is a Palindrome Word
Input: None
Output: None isn't a Palindrome Word
Input: Hello
Output: Hello isn't a Palindrome Word
I solved it using a `while` loop to reverse the string and then
compared it with the original string.
💡 Pro Tip: You can also solve this in one line using slicing!
💬 How would you handle case-insensitive palindromes like `"RaceCar"`?
Thanks For Reading
Abdullah Shayed
If you think it’s helpful —
Please Follow Me For More Dev Tips
#Python #Palindrome #ProblemSolving #LearnToCode #PythonTips