title: Python: base case of a recursive function
body: <p>Currently I'm experimenting a little bit with recursive functions in Python. I've read some things on the internet about them and I also built some simple functioning recursive functions myself. Although, I'm still not sure how to use the base case.</p>
  
  <p>I know that a well-designed recursive function satisfies the following rules:</p>
  
  <ul>
  <li>There is a base case.</li>
  <li>The recursive steps work towards the base case.</li>
  <li>The solutions of the subproblems provide a solution for the original problem.</li>
  </ul>
  
  <p>Now I want to come down to the question that I have: Is it allowed to make up a base case from multiple statements?</p>
  
  <p>In other words is the base case of the following self written script, valid?</p>
  
  <pre><code>def checkstring(n, string):
  
   if len(string) == 1:
      if string == n:
          return 1
      else:
          return 0
  
  
   if string[-1:] == n:
      return 1 + checkstring(n, string[0:len(string) - 1])
   else:
      return checkstring(n, string[0:len(string) - 1])
  print(checkstring('l', 'hello'))
  </code></pre>