Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
line = input("Enter a sentence: ")
words = line.split()
counts = {}
for word in words:
counts[word] = counts.get(word, 0) + 1
for word in counts:
print(word, ":", counts[word])