title: Finding the most frequent character in a string
body: <p>I found this programming problem while looking at a job posting on SO. I thought it was pretty interesting and as a beginner Python programmer I attempted to tackle it. However I feel my solution is quite...messy...can anyone make any suggestions to optimize it or make it cleaner? I know it's pretty trivial, but I had fun writing it. Note: Python 2.6</p>
  
  <p><strong>The problem:</strong></p>
  
  <p>Write pseudo-code (or actual code) for a function that takes in a string and returns the letter that appears the most in that string.</p>
  
  <p><strong>My attempt:</strong></p>
  
  <pre><code>import string
  
  def find_max_letter_count(word):
  
      alphabet = string.ascii_lowercase
      dictionary = {}
  
      for letters in alphabet:
          dictionary[letters] = 0
  
      for letters in word:
          dictionary[letters] += 1
  
      dictionary = sorted(dictionary.items(), 
                          reverse=True, 
                          key=lambda x: x[1])
  
      for position in range(0, 26):
          print dictionary[position]
          if position != len(dictionary) - 1:
              if dictionary[position + 1][1] &lt; dictionary[position][1]:
                  break
  
  find_max_letter_count("helloworld")
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>&gt;&gt;&gt; 
  ('l', 3)
  </code></pre>
  
  <p>Updated example:</p>
  
  <pre><code>find_max_letter_count("balloon") 
  &gt;&gt;&gt;
  ('l', 2)
  ('o', 2)
  </code></pre>