Skip to content

Instantly share code, notes, and snippets.

@thomastschinkel
Created January 24, 2025 17:03
Show Gist options
  • Save thomastschinkel/6ea702f80eb5b13d0dc57cbaee003b70 to your computer and use it in GitHub Desktop.
Save thomastschinkel/6ea702f80eb5b13d0dc57cbaee003b70 to your computer and use it in GitHub Desktop.
A simple word counter in Python
# word counter
text = input("Enter text to count the words: ").strip()
words = len(text.split())
if words == 1:
print(f"The text: \"{text}\" has {words} word.")
else:
print(f"The text: \"{text}\" has {words} words.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment