CJCoding With Joseph
15free / daySign inCreate account

Count Each Letter

Read one word from the input (one line, no prompt) and count how many times each letter appears, using a dict whose keys are the letters. Inside the loop over the characters, use in to check whether the letter is already a key: add one to its count if so, otherwise store it with a count of 1. After the loop print the whole dict. Input: one line. Output: one line, the printed dict, letters in the order they were first seen.

Expected Output:

{'b': 1, 'a': 3, 'n': 2}

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Dictionaries
📥 Auto-Input:
banana\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.