def is_palindrome(s: str) -> bool:
# Keep only letters and digits, lowercased
cleaned = [ch.lower() for ch in s if ch.isalnum()]
return cleaned == cleaned[::-1]
# Test cases
assert is_palindrome("A man, a plan, a canal: Panama") is True
assert is_palindrome("Hello, world!") is False
assert is_palindrome("No 'x' in Nixon") is True
The function filters the string down to alphanumeric characters, lowercases them, and compares the resulting list to its reverse. Using isalnum() strips spaces and punctuation in one step. An empty string or one with no alphanumerics returns True, which is the usual convention.