Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
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.