Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion fixit/textutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/test_textutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Loading