Skip to content
Exercise · Strings · lesson 10 of 10

Exercise: palindrome

Write a function is_palindrome(text) that returns True if the string text is a palindrome and False otherwise. A palindrome reads the same from left to right and from right to left, ignoring letter case and spaces.

  • is_palindrome("Racecar") → True
  • is_palindrome("never odd or even") → True
  • is_palindrome("python") → False

Constraints: text consists of Latin or Russian letters and spaces; the empty string is a palindrome.

Do not add extra imports unless the task says so explicitly.

palindrome.py — python
python · 3 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way