Word Count
Background
Counting the number of words in a document is a common task in text processing and analysis. A word is typically defined as a sequence of characters separated by whitespace.
Task
Write a function word_count(s: str) -> int that takes a string and returns the number of words it contains.
Specifications
- Input: A string
sof arbitrary length. - Output: An integer representing the total count of words.
Constraints
- Do not use
input()orprint(). - Words are separated by any amount of whitespace (spaces, tabs, newlines).
- An empty string or a string with only whitespace should return
0.
Example
Instructions
Implement the function in solution.py.