Created
January 24, 2025 17:03
-
-
Save thomastschinkel/6ea702f80eb5b13d0dc57cbaee003b70 to your computer and use it in GitHub Desktop.
A simple word counter in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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