Editor

Palindrome Check

#17 · Strings · Intermediate · 60 XP · about 6 min

Write a function called is_palindrome(s) that returns True if the string is a palindrome (reads the same forwards and backwards), and False otherwise.

The check should be case-insensitive and ignore spaces.

Example

is_palindrome("racecar")      # Returns True
is_palindrome("hello")        # Returns False
is_palindrome("A man a plan a canal Panama")  # Returns True
is_palindrome("Was it a car or a cat I saw")  # Returns True

Requirements

  • Ignore case (treat 'A' and 'a' as the same)
  • Ignore spaces
  • Return a boolean

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.