Scenario
Given a few lines of code, I have included the line
counts = Counter(rank for rank in ranks)
because I want to find the highest count of a character in a string.
So I end up with the following object:
Counter({'A': 4, 'K': 1})
Here, the value I'm looking for is 4
, because it is the highest count. Assume the object is called counts
, then max(counts)
returns 'K'
, presumably because 'K' > 'A'
in unicode.
Question
How can I access the largest count/value, rather than the "largest" key?