Palindrome Checker
Medium
Write a function is_palindrome(s) that returns True if the string is a palindrome, False otherwise.
A palindrome reads the same forwards and backwards. Ignore case and spaces.
Examples:
- "racecar" → True
- "A man a plan a canal Panama" → True
- "hello" → False
A palindrome reads the same forwards and backwards. Ignore case and spaces.
Examples:
- "racecar" → True
- "A man a plan a canal Panama" → True
- "hello" → False
Input
A string
Output
True or False
Example
Input
racecar
Output
True
Remove spaces, convert to lowercase, then compare with its reverse using [::-1].
⚡ 20 XP on solve
← Back to lesson
Your Solution
Output
Click "Run" to execute your code...
⏳ Loading Python runtime (first run may take a few seconds)...
Log in to submit your solution and earn XP.