livepython.net

118. Python Program to Count Each Letter in a Word

MediumLooping

Overview

Use a dictionary as a counter: each letter is a key, and its value is how many times it appears.

Problem Statement

Read a word and count how many times each character appears. Capital and small letters count as different characters. Then print one line per character in the format a: 3, in the order each character first appears in the word. For example, for banana:

b: 1
a: 3
n: 2

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order. Example:

banana

Output

The output for that example:

b: 1
a: 3
n: 2

The tests try 4 different inputs.

Learn this firstChapter 13 · Loop Through a Dictionary in Python
solution.py
# write your code here

EXPECTED OUTPUT

1b: 1
2a: 3
3n: 2

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.