Count how often each word appears in a block of text. Words are compared case-insensitively and are made of letters, digits and apostrophes; everything else separates words.
Return a dictionary mapping each lowercase word to its count. Key order does not matter.
Implement word_counts. Input: text: str. Returns: dict[str, int].
def word_counts(text: str) -> dict[str, int]:
counts = {}
# Your code here
return counts
Run executes the public tests. Submit grades against public and hidden tests.
Count how often each word appears in a block of text. Words are compared case-insensitively and are made of letters, digits and apostrophes; everything else separates words.
Return a dictionary mapping each lowercase word to its count. Key order does not matter.
Implement word_counts. Input: text: str. Returns: dict[str, int].
def word_counts(text: str) -> dict[str, int]:
counts = {}
# Your code here
return counts
Run executes the public tests. Submit grades against public and hidden tests.