How to print the most times a char occurs from a counter in python
<pre><code>Counter(str)
print max(Counter(str))
</code></pre>

<p>When this prints, it will print the letter in the string that occurs the most, I want to print how many times it occurs not what letter. How do I go about doing this?</p>

<p>The <code>collections.Counter</code> object already provides a method for this - <a href="https://docs.python.org/2/library/collections.html#collections.Counter.most_common" rel="nofollow"><code>most_common</code></a>:</p>

<blockquote>
  <p>Return a list of the <code>n</code> most common elements and their counts from
  the most common to the least. If <code>n</code> is omitted or <code>None</code>,
  <code>most_common()</code> returns all elements in the counter. Elements with
  <strong>equal counts</strong> are ordered <strong>arbitrarily</strong></p>
</blockquote>

<p><em>Emphasis mine</em></p>

<pre><code>print Counter(my_str).most_common(1)
</code></pre>

python counter