title: How to generalize a function by adding arguments?
body: <p>I am completing a beginner's Python book.
  I think I understand what the question is asking.</p>
  
  <p><strong>Encapsulate into a function, and generalize it so that it accepts the string and the letter as arguments.</strong></p>
  
  <pre><code>fruit = "banana"
  count = 0
  for char in fruit:
      if char == 'a':
          count += 1
  print count
  </code></pre>
  
  <p><strong>My answer is:</strong></p>
  
  <pre><code>def count_letters(letter, strng):
      fruit = strng
      count = 0
      for char in fruit:
          if char == letter:
              count += 1
      print count
  
  count_letters(a, banana)
  </code></pre>
  
  <p>But it is wrong: <em>name 'a' is not defined</em>. I don't know where I'm going wrong.
  I thought the interpreter should know that 'a' is the argument for 'letter', and so on.</p>
  
  <p>So I must be missing something fundamental.</p>
  
  <p>Can you help?</p>