Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one word and print yes if it reads the same forwards and backwards, otherwise no.
Ignore case: Level should count as a palindrome.
Input. One line: a word.
Output. yes or no (lowercase).
Examples
Input
Level
Output
yes
Input
python
Output
no
Hint
- Lowercase the word first so case does not break the comparison.
- A string equals its own reverse exactly when it is a palindrome: s == s[::-1].
Show correct code
Peek only after you have tried. You can still Check your own version.
s = input().strip().lower()
print("yes" if s == s[::-1] else "no")
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.