title: Python Adding Binary Numbers Using "Elementary School" Algorithm
body: <p>I have to write a code that takes two input binary numbers (as strings) and add them using the "elementary school" algorithm. This is what the code input and output should look like:</p>
  
  <pre><code>&gt;&gt;&gt;addBinary("11","1")
  '100'
  </code></pre>
  
  <p>I have tried writing some code myself but I am stuck:</p>
  
  <pre><code>def addBinary(s,t, b = 0):
      if '' == s or '' == t:
          return s + t
      if 1 == len(s) or 1 == len(s):    
          if 0 == b:
              if (0 == s[-1] and 1 == t[-1]) or (1 == s[-1]and 0 == t[-1]):
                  return addBinary(s[:-1],t[:-1]) + '1'
              elif 0 == s[-1] and 0 == t[-1]:
                  return addBinary(s[:-1],t[:-1]) + '0'
              else:
                  return addBinary(s[:-1],t[:-1],1) + '0'
          else:
              if (0 == s[-1] and 1 == t[-1]) or (1 == s[-1]and 0 == t[-1]):
                  return addBinary(s[:-1],t[:-1],1) + '0'
              elif 0 == s[-1] and 0 == t[-1]:
                  return addBinary(s[:-1],t[:-1]) + '1'
              else:
                  return addBinary(s[:-1],t[:-1],1) + '0'
  </code></pre>
  
  <p>I am having trouble for when I get down to 1 element left in the string. I am having trouble creating my base case</p>
  
  <p>PS: I have to use recursion for this code. I am not allowed to use loops.</p>