Question
In python from the text-file how to get a max and min word length? Let's say thousands names in the text file how to get
In python from the text-file how to get a max and min word length? Let's say thousands names in the text file how to get a maximum word length and min word length? Here is my code below I already got tot# of words, char, and avg
but I don't know how to get max and min
also if you can help me with counting distribution length for all words from textile arranged like Length 0 = n0 words~ Length 8 = n8 words
Thank you
File=open("/Users/Daniell/Desktop/Python/words_file.txt",'r') To_Read=File.read()
count_num=To_Read.splitlines() #Tot num of counts characters_num=To_Read #Tot num of characters words = To_Read.split() average = sum(len(word) for word in words) / len(words)
print("Total number of words in the file:", str (len(count_num))) print("Total number of characters in all the words in the file:" , str (len(To_Read))) print("Average length of words in the file (rounded to two decimal digits):", round(average, 2) )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started