Write a program to take a string and print all the words and their frequencies


Topic: Write a program to take a string and print all the words and their frequencies

Solution

string_words = '''This assignment is of 900 marks. Each example if 9 marks.
If your example is similar to someone else, then you score less.
The formula we will use is 9/(repeated example). That means if 9 people write same example,
then you get only 1. So think different! (if examples are mentioned here and in the sample file, you will score less)'''
word_list = string_words.split()
word_freq = [word_list.count(n) for n in word_list]
print("Pairs (Words and Frequencies:\n {}".format(str(list(zip(word_list, word_freq)))))



List all Python Programs