Summary
Determine whether a string reads the same forwards and backwards, ignoring case and non-alphanumeric characters.
Problem statement
Implement is_palindrome(s) which returns True if s is a palindrome and False otherwise. For this problem, ignore case and non-alphanumeric characters (spaces, punctuation). That means only letters and digits are considered when checking for palindrome behavior.
Task
Learn normalization techniques: lowercasing and filtering characters, then compare to the reversed sequence to detect palindromes.
Examples
Palindrome with mixed case
Input
is_palindrome('Racecar')
Output
True
Explanation
Ignoring case, 'racecar' reads the same forwards and backwards.
Input format
A single string s passed as the argument to is_palindrome(s).
Output format
Return a boolean True if s is a palindrome (per rules), otherwise False.
Constraints
0 <= len(s) <= 10^5. Only ASCII letters and digits (and other unicode alphanumerics) are considered; punctuation and spaces are ignored.
Samples
Sample input 0
is_palindrome('A man, a plan, a canal: Panama')
Sample output 0
True
Explanation 0
After removing non-alphanumerics and lowercasing, the string becomes a man a plan a canal panama -> palindrome.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.