Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 11

Is Palindrome String

Easy

8 minute session

Summary

Determine whether a string reads the same forwards and backwards, ignoring non-alphanumeric characters and case.

Problem statement

Write a function is_palindrome(s) that returns True if the input string s is a palindrome when considering only alphanumeric characters and ignoring case; otherwise return False. An empty string (or a string with no alphanumeric characters) should be considered a palindrome.

Task

Practice conditional logic and simple string processing to detect palindromes.

Examples

Simple palindrome

Input

'racecar'

Output

True

Explanation

The string "racecar" reads the same forwards and backwards.

Input format

A single string argument s.

Output format

Return True if s is a palindrome (ignoring non-alphanumerics and case), otherwise False.

Constraints

Do not use external libraries. Handle empty strings and strings with punctuation.

Samples

Sample input 0

"A man a plan a canal Panama"

Sample output 0

True

Explanation 0

Ignoring spaces and case, it's a palindrome.

Code editor
Loading editor…

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.

03:50 AM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.