File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Number-Guess/TextAnalyzer Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments