#C14692. Letter Frequency
Letter Frequency
Letter Frequency
Given a string, compute the frequency of each letter ignoring case and non-letter characters. The task is to output a dictionary that maps each lowercase letter to its count. Only letters that occur in the string are included. For example, for the input Hello, World!
, the expected output is {'d': 1, 'e': 1, 'h': 1, 'l': 3, 'o': 2, 'r': 1, 'w': 1}
(letters are sorted alphabetically in the output). Equations, if any, should be rendered in LaTeX format (e.g., ).
inputFormat
A single line input from STDIN containing the string. The string may include spaces, punctuation, and mixed case letters.
outputFormat
Print to STDOUT a dictionary representation of the letter frequency with keys sorted in alphabetical order. The format should be exactly as follows: {'a': count, 'b': count, ...}
. If the string contains no letters, output {}
.## sample
Hello
{'e': 1, 'h': 1, 'l': 2, 'o': 1}