Files
vibe-test/stringutils.py
wralto-user-1 0b6fe9d244 feat: add stringutils module with word_count function and tests
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-02 22:14:51 +01:00

15 lines
364 B
Python

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())