Strings and text · Python exercise
Check whether a phrase reads the same forwards and backwards.
Read one line of text and print Palindrome if it reads the same backwards, otherwise print Not palindrome. Ignore case, spaces, and punctuation.
Example 1
Input
racecar
Output
Palindrome
Example 2
Input
hello
Output
Not palindrome
Example 3
Input
A man, a plan, a canal: Panama
Output
Palindrome
The cleaned phrase is amanaplanacanalpanama.
How testing works
Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.
Loading editor…
Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.