S = str(input("Enter a sentence: \n"))
str = S.split()
tempS=[]
for i in str:
if i not in tempS:
tempS.append(i)
print("Input Sentence:\n" + S)
print("\nWord Frequency")
for i in range(0, len(tempS)):
print("%9s:%5s"%(tempS[i].ljust(20),str.count(tempS[i])))
Comments
Leave a comment