DEV Community

Cover image for Day 24 of My 90 Days Python Series – Word Counter Tool
momina raheel (Moona)
momina raheel (Moona)

Posted on

Day 24 of My 90 Days Python Series – Word Counter Tool

πŸš€ 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! 🧑
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ 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)