0 like 0 dislike
4 views
in Python by (1.5k points)

Python Exercise: Word Frequency Counter

Task

Write a Python program that:

1. Takes a sentence as input from the user.

2. Counts how many times each word appears.

3. Prints the result in sorted order (alphabetically).

Example Input

Enter a sentence: this is a test this is good

Expected Output

a: 1

good: 1

is: 2

test: 1

this: 2

Hints

Convert input to lowercase.

Use .split() to break words.

Use a dictionary {} to store counts.

Use sorted() before printing.

Please log in or register to answer this question.

Welcome to Mcqbuddy Q&A, where you can ask questions and receive answers from other members of the community.
...