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.