Discussion about this post

User's avatar
Kuldeep sharma's avatar

def length_analyser(a):

b=len(a)

c=len(a.split(' '))

d=a.count(".") + a.count("?") + a.count("!")

test1=a.split(' ')

n=0

for i in test1:

n+=len(i)

return b ,c,d,n/len(test1),c/d

def freq_word(a):

test={}

test1=a.split(' ')

for i in test1:

test[i]=test1.count(i)

word=max(test,key=test.get)

return word , test[word]

x= input("enter a bloxk of text for analysis:")

char_count,word_count,line_count,avg_word_len,avg_sent_len=length_analyser(x)

z,f=freq_word(x)

print("Total number of charaters {}".format(char_count) )

print("Total number of words {}".format(word_count) )

print("Total number of lines {}".format(line_count) )

print("Most frequest word used is {} . it is used {} times".format(z,f) )

print("Average word length is {}".format(avg_word_len) )

print("Average sentence length is {}".format(avg_sent_len) )

No posts

Ready for more?