title: Recursion and bissection search to find character: missing 1 required positional argument
body: <p>I am currently trying to learn Python 3 through <strong>MITx: 6.00.1x Introduction to Computer Science and Programming Using Python</strong>, and I got stuck in the following exercise (kind of):</p>
  
  <blockquote>
    <p>We can use the idea of bisection search to determine if a character is in a string, so long as the string is sorted in alphabetical order.</p>
    
    <p>First, test the middle character of a string against the character you're looking for (the "test character"). If they are the same, we are done - we've found the character we're looking for!</p>
    
    <p>If they're not the same, check if the test character is "smaller" than the middle character. If so, we need only consider the lower half of the string; otherwise, we only consider the upper half of the string. (Note that you can compare characters using Python's &lt; function.)</p>
    
    <p>Implement the function isIn(char, aStr) which implements the above idea recursively to test if char is in aStr. char will be a single character and aStr will be a string that is in alphabetical order. The function should return a boolean value.</p>
  </blockquote>
  
  <p>My code is the following:</p>
  
  <pre><code>def isIn(char, aStr):
      '''
      char: a single character
      aStr: an alphabetized string
  
      returns: True if char is in aStr; False otherwise
      '''
  # makes the string and character lower case and removes special characters from string
  def lower_string(char, aStr):
      aStr = aStr.lower()
      char = char.lower()
      ans = ""
      for i in 'abcdefghijklmnopqrstuvwxyz':
          if i in aStr:
              ans += i
          return ans
  
  def isInTrue(char, aStr):
      if char == aStr[len(aStr)//2]:
          return True
      elif len(aStr) == 1 and char != aStr:
          return False
      elif len(aStr) == 1 and char == aStr:
          return True
      elif len(aStr) == 0:
          return False
      else:
          if char &gt; aStr[len(aStr)//2]:
              return isInTrue(char, aStr[len(aStr)//2:])
          else:
              return isInTrue(char,aStr[:len(aStr)//2])
  
  return isInTrue(lower_string(char, aStr))
  </code></pre>
  
  <p>I created a more simple version of this code, too, because the code above wouldn't run:</p>
  
  <pre><code>def isIn(char, aStr):
      '''
      char: a single character
      aStr: an alphabetized string
  
      returns: True if char is in aStr; False otherwise
      '''
      if len(aStr) == 0:
          return False
      elif len(aStr) == 1 and char != aStr:
          return False
      elif len(aStr) == 1 and char == aStr:
          return True
      elif char == aStr[len(aStr)//2]:
          return True
      else:
          if char &gt; aStr[len(aStr)//2]:
              return isIn(char, aStr[len(aStr)//2:])
          else:
              return isIn(char, aStr[:len(aStr)//2])
  </code></pre>
  
  <p>My issue is:</p>
  
  <p>If I run the first, more complex, code with <strong>char = "o"</strong> and <strong>aStr = "abcdefopq"</strong>, I get the error: <strong>isInTrue() missing 1 required positional argument: 'aStr'</strong>. I don't understand why this happens; I have checked the code several times and failed to find what's missing (but this is surely my fault).</p>
  
  <p>The second, more simple, code works as expected.</p>
  
  <p>If someone could explain me what's wrong in my code, I'd be very thankful. I have spent at least two hours on this problem, and I am starting to question whether Python (or programming in general) is meant for me. </p>
  
  <p>Thanks.</p>