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
3 changes: 2 additions & 1 deletion fixit/wordcount.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import re
"""Word, line and character counting."""


def count_words(text: str) -> int:
"""Return the number of words in text."""
return len(text.split(" "))
return len(re.split(r'\s+',text.strip()))


def count_lines(text: str) -> int:
Expand Down
1 change: 0 additions & 1 deletion tests/test_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def test_count_words_simple():
assert count_words("hello world") == 2


@pytest.mark.xfail(reason="Known bug: multiple spaces are counted as words")
def test_count_words_extra_spaces():
assert count_words("hello world") == 2

Expand Down