#C13064. Alphabet Frequency Count
Alphabet Frequency Count
Alphabet Frequency Count
Given a string S
, count the occurrences of each alphabet letter regardless of case, ignoring non-alphabet characters. The output should be a dictionary (or map) where each key is a lowercase alphabet character and the corresponding value is the count of that character in the string.
The order of the keys in the output should follow the order in which the letter first appears in the input string.
For example, given the input Hello, World! 123
, the output should be {'h': 1, 'e': 1, 'l': 3, 'o': 2, 'w': 1, 'r': 1, 'd': 1}
.
Note: You should read input from the standard input (stdin) and output your result to the standard output (stdout). If any formulas are referenced, they must be in LaTeX format, e.g. $[A-Za-z]$ represents any alphabet letter.
inputFormat
The input consists of a single line string S
. This string may contain letters, digits, spaces, and punctuation.
outputFormat
Print the resulting dictionary in the following format: {'a': count_a, 'b': count_b, ...}
where the keys appear in the order of their first occurrence in S
and only the alphabet letters that appear in the input are included. The letters should be output in lowercase.
Hello, World! 123
{'h': 1, 'e': 1, 'l': 3, 'o': 2, 'w': 1, 'r': 1, 'd': 1}