diff --git a/fixit/textutils.py b/fixit/textutils.py index ce615a0..76ecbdf 100644 --- a/fixit/textutils.py +++ b/fixit/textutils.py @@ -8,7 +8,13 @@ def is_palindrome(text: str) -> bool: is_palindrome("madam") returns True. is_palindrome("hello") returns False. """ - return text == text[::-1] + + cleaned = "".join( + ch.lower() + for ch in text + if ch.isalnum() + ) + return cleaned == cleaned[::-1] def reverse_words(text: str) -> str: diff --git a/tests/test_textutils.py b/tests/test_textutils.py index a51a607..58fe2ce 100644 --- a/tests/test_textutils.py +++ b/tests/test_textutils.py @@ -11,7 +11,6 @@ def test_palindrome_ignores_case(): assert is_palindrome("Level") -@pytest.mark.xfail(reason="Known bug: spaces and punctuation are not ignored") def test_palindrome_ignores_punctuation(): assert is_palindrome("A man, a plan, a canal: Panama")