Skip to content

Commit 083a7a1

Browse files
committed
Added Text Analyzer mini project
1 parent 55eb126 commit 083a7a1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Number-Guess/TextAnalyzer/README.md

Whitespace-only changes.

Number-Guess/TextAnalyzer/Text.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from collections import Counter
2+
3+
def analyze_text(text):
4+
words = text.split()
5+
total_words = len(words)
6+
total_chars = len(text)
7+
total_no_spaces = len(text.replace(" ", ""))
8+
9+
most_common_word = Counter(words).most_common(1)[0]
10+
11+
print("\n📊 Text Analysis Results:")
12+
print(f"➡️ Total words: {total_words}")
13+
print(f"➡️ Total characters (with spaces): {total_chars}")
14+
print(f"➡️ Total characters (without spaces): {total_no_spaces}")
15+
print(f"➡️ Most used word: '{most_common_word[0]}' ({most_common_word[1]}x)")
16+
17+
def main():
18+
print("🧠 Text Analyzer — Python Project")
19+
text = input("Enter or paste the text you want to analyze:\n\n")
20+
analyze_text(text)
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)