π Day 24 of My 90 Days Python Series β Word Counter Tool
Are you also struggling to keep track of how many words, sentences, or characters your text has? π©
If yes β this little Python project will save you the headache!
π§ Why I Built This
Counting words or sentences manually can be boring, and remembering formulas makes it worse.
So, I built a Python Word Counter Tool that does all the work for me β automatically! π»
Itβs simple, runs in the terminal, and is perfect for beginners learning loops, conditionals, and string handling.
β¨ What It Can Do
β
Counts total words in your text
β
Counts characters (excluding spaces)
β
Detects sentences based on punctuation
β
Keeps running until you choose to exit
βοΈ How It Works
Hereβs a small example π
β¨ Welcome to the Word Counter Tool β¨
Enter your text or paragraph:
Python is amazing! It makes programming fun and creative.
π Your Text Summary π
Words: 8
Characters (without spaces): 48
Sentences: 2
Do you want to analyze another text? (yes/no): no
Thanks for using the Word Counter Tool! π§‘
Itβs super easy β no setup, no extra libraries.
Just run, type your text, and get your instant stats!
π‘ Concepts Used
- Loops (
while
,for
) - Conditional logic (
if
,else
) -
String methods:
-
split()
β separates words -
replace()
β removes spaces -
strip()
β cleans text
-
Counting logic for characters and sentences
π§© Code Overview
Hereβs the simplified version of the logic:
while True:
text = input("Enter your text: ")
words = text.split()
word_count = len(words)
char_count = len(text.replace(" ", ""))
sentence_count = sum(ch in ".!?" for ch in text)
print(f"Words: {word_count}")
print(f"Characters (no spaces): {char_count}")
print(f"Sentences: {sentence_count}")
again = input("Do you want to continue? (yes/no): ").lower()
if again != "yes":
break
π GitHub Repository
Check out the full project here π
π https://github.com/shadowMomina/python-word-counter-tool.git
π Final Thoughts
This is Day 24 of my 90 Days Python Series β where I build small, fun, and practical projects every day to strengthen my Python foundation. π
If youβre also learning Python, try this project and see how much text you can analyze!
Remember β building something every day is the best way to learn. πͺ
Stay tuned for Day 25 β something even more exciting is coming! π
Top comments (0)