Valid palindrome

Is a sentence a palindrome? Ignore everything that is not a letter or a digit, and ignore the difference between capitals and small letters.

Input

One line of text (up to 10⁵ characters, possibly with spaces and punctuation).

Output

yes or no.

Examples

Example 1 · Input
A man, a plan, a canal: Panama
Expected output
yes
Example 2 · Input
race a car
Expected output
no

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Two pointers, one from each end.

Hint 2

Skip characters that are not letters or digits (str.isalnum).

Hint 3

Compare with .lower(), so capitals do not matter.

Solution

Show one correct solution (try it yourself first)
s = input()
left, right = 0, len(s) - 1
ok = True
while left < right:
    if not s[left].isalnum():
        left += 1
    elif not s[right].isalnum():
        right -= 1
    elif s[left].lower() != s[right].lower():
        ok = False
        break
    else:
        left += 1
        right -= 1
print("yes" if ok else "no")

Lesson: Two pointers →