Python interview question: valid palindrome
Problem
For anniversary “mirror” promo codes, return True if code reads the same in both directions, ignoring case and every character that isn’t a letter or a digit. Letters aren’t only A–Z: ñ and é count too. An empty code counts as a mirror.
def is_mirror_code(code: str) -> bool:
Example
code = 'Rotor-7-rotor' → Truehyphens are skipped, and R matches rcode = 'Kayak 2026 kayak' → False2026 reversed is 6202
Solve it free
Checked against hidden tests, right in your browser. No sign-up needed.