I'd like to count the number of strings in an ordered dict that start with a particular string. For example, I have the following ordered dict:
OrderedDict([('Name', 'First'), ('Size': '10'), ('Rate 1', '1000'), ('Rate 2', '100'), ('End', 'Last'])
I want to count the number of keys that start with "Rate". In this example, it would be 2.
I tried n = len(o_dict.keys().startswith('Rate'))
with but this results in AttributeError: 'odict_keys' object has no attribute 'startswith'
.
Any idea what to do here? Thanks in advance.
Output