Unit 3 Task 13: Word tally from a sentence

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 3 Task 13 - Word tally from a sentence

← Unit 3 tasks - Solution


Read one line of text from the user. Split it into words with .split() (spaces separate words).

Build a dictionary: each word maps to how many times it appeared. Start with an empty dict. For each word, update the count (use .get(word, 0) + 1 or check if word in counts).

Print each word and its count on its own line (order does not matter).

Skills: split(), dict counting pattern.