#K55192. Count Characters in a String
Count Characters in a String
Count Characters in a String
Given a string, count the number of occurrences of each character. You should output a dictionary-like string (in the style of Python's dictionary) where each key is a character enclosed in single quotes and its corresponding value is the number of times it appears in the string. The order of the keys should be the same as the order in which they first appear in the input string.
For example, if the input is abracadabra
, the output should be {'a': 5, 'b': 2, 'r': 2, 'c': 1, 'd': 1}
.
Make sure that your solution reads input from stdin and writes the result to stdout in exactly the required format.
inputFormat
The input consists of a single line of text, which is the string for which the character counts are to be computed.
outputFormat
Output a dictionary-like string representing each character in the input and its count. The keys should be enclosed with single quotes and listed in the order of their first occurrence. For an empty string, output {}.## sample
{}