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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!