title: Building 'Find' function in Python
body: <p>I have been learning Python (as my first language) from <em>"How to Think Like a Computer Scientist: Learning with Python"</em>. This open book teaches mostly through examples and I prefer to read the goal and build the program on my own, rather than actually reading the program code provided in the book.</p>
  
  <p>However, I am struggling with creating a function which will search for a specific character in a given string and return how many times that character was counted.</p>
  
  <p>The code I wrote is:</p>
  
  <pre><code>def find(s, x): #find s in x
      s = raw_input("Enter what you wish to find: ")
      x = raw_input("Where to search? ")
      count = 0
      for l in x: #loop through every letter in x
          if l == s: 
              count += 1
          else:
              print count
  </code></pre>
  
  <p>However, when I run this code, I get the error "<strong>name 's' is not defined</strong>".</p>
  
  <p>The code in the book has a slightly different goal: it searches for a specific character in a string, but instead of counting how many times the character was found, it returns the position of the character in the string.</p>
  
  <pre><code>def find(strng, ch, start=0, step=1):
      index = start
      while 0 &lt;= index &lt; len(strng):
          if strng[index] == ch:
              return index
          index += step
      return -1
  </code></pre>
  
  <p>I don't really understand this code, actually.
  However, even when I run the code, for example, to search for <code>'a'</code> in <code>'banana'</code>, I get the error <code>name 'banana' is not defined</code>.</p>
  
  <p>What is wrong with my code? Could please someone explain me how the code provided in the book works?</p>