def word_count(text: str) -> int: """Count the number of words in a string. Words are defined as non-empty sequences separated by whitespace. Args: text: The input string to count words in. Returns: The number of words in the string. """ if not text.strip(): return 0 return len(text.split())