A simple Python package to count words and characters.
Project description
A simple Python package that counts words & characters in any given text. Useful for text processing, analytics, and word-based analysis. 🚀
Installation
Install this package using pip:
pip install word-count-package
Importing the Package
Once installed, import it into your Python script:
import wordcount
Available Functions
count_words_and_chars(text) This function counts words and characters in a given text.
Function Signature
wordcount.count_words_and_chars(text: str) -> dict
Parameters
Parameter |
Type |
Description |
|---|---|---|
text |
str |
The input text to analyze |
Returns
This function returns a dictionary containing:
“words” → Number of words in the text.
“characters” → Number of characters in the text.
Example Usage
Create a Python script (e.g., test_script.py) and use the package:
import wordcount
text = "Python packaging is fun and useful!"
result = wordcount.count_words_and_chars(text)
print(f"Words: {result['words']}, Characters: {result['characters']}")
✅ Expected Output:
Words: 6, Characters: 37
More Examples
result = wordcount.count_words_and_chars("Hello world!")
print(result)
Output:
{'words': 2, 'characters': 12}
result = wordcount.count_words_and_chars("This is a Python package example.")
print(result)
Output:
{'words': 6, 'characters': 35}
Updating the Package
If a new version is released, upgrade using:
pip install --upgrade word-count-package
Supported Environments
✅ Windows (Command Prompt, PowerShell) ✅ macOS (Terminal) ✅ Linux (Bash, Zsh, etc.)
Works with Python 3.6+.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file word_count_package-1.0.2.tar.gz.
File metadata
- Download URL: word_count_package-1.0.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d51c63b2e5e98d5c25f89cfef642adec4ae6d306cbd4b36a74beb695e23f20f2
|
|
| MD5 |
b34ad2924d44950718480afc9727585f
|
|
| BLAKE2b-256 |
b99f108348e6a5532abc34320d25b95162d422e8c65f96ea8859b9808394356d
|
File details
Details for the file word_count_package-1.0.2-py3-none-any.whl.
File metadata
- Download URL: word_count_package-1.0.2-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ccd1f5f3873100adac98c7348fca4cb84b9e33479c257e573fc98c5e58aeeaf
|
|
| MD5 |
076122efbd4603e05f70dfa596ce908e
|
|
| BLAKE2b-256 |
03fee88cc92dc54979b8060aa6542ba635ba56dcb23376d7fcb92c6a1bfada0c
|