Frequency Dictionary

Report a typo

When Anton finished reading "War and Peace", he decided to find out the number of specific words used in the book. Help Anton write a simplified version of such a program that will be capable of counting the words separated by spaces and print the statistics.

The code should:

  1. Prompt the user to input a sentence.

  2. Count the occurrence of each unique word in the sentence.

  3. Print the results, showing each word and its frequency.

Additional details:

  • Treat the input as case-insensitive (e.g., "The" and "the" should be counted as the same word).

  • Words are assumed to be separated by spaces.

  • Each word should be printed only once in the output, regardless of its frequency.

  • The output format for each word should be: word frequency (e.g., sun 3).

  • The order of words in the output doesn't matter.

Sample Input 1:

a aa abC aa ac abc bcd a

Sample Output 1:

a 2
aa 2
abc 2
ac 1
bcd 1

Sample Input 2:

a A a

Sample Output 2:

a 3
Write a program in Python 3
# put your python code here
___

Create a free account to access the full topic