Challenge: Count with Dictionary

Count occurrences with the dictionary.

Problem statement

In this challenge, write a function count_letters(message) that counts occurrences of each letter in message using the defaultdict type dictionary, and then sorts the items on the basis of values using OrderedDict.

Input

A string

Output

A dictionary of type OrderedDict

Sample input

'Welcome to Educative'

Sample output

OrderedDict([('d', 1), ('a', 1), ('i', 1), ('l', 1), ('v', 1), ('W', 1), ('m', 1), ('u', 1), ('E', 1), ('c', 2), ('t', 2), (' ', 2), ('o', 2), ('e', 3)])

Get hands-on with 1200+ tech skills courses.