Files
troupe-standup/wizard-work/spark/word_counter_simple.py
T

13 lines
387 B
Python

#!/usr/bin/env python3
"""Simple word counter - counts words in a string."""
def count_words(text):
"""Return the number of whitespace-separated words in text."""
if not text:
return 0
return len(text.split())
if __name__ == "__main__":
import sys
text = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "hello world from spark"
print(count_words(text))