I have a dictionary that looks like this
MyCount= {u'10': 1, u'1': 2, u'3': 2, u'2': 2, u'5': 2, u'4': 2, u'7': 2, u'6': 2, u'9': 2, u'8': 2}
I need highest key which is 10 but i if try max(MyCount.keys()) it gives 9 as highest.
Same for max(MyCount).
The dictionary is created dynamically.
This is because
u'9' > u'10', since they are strings.To compare numerically, use
intas a key.(Calling
.keys()is usually unnecessary)