title: Variables reset with every recursive call so function doesn't work. (Python)
body: <p>Code:</p>
  counter and storage are reset every time the function is called recusively
  <pre><code>def bin_to_dec(b):    
      '''Takes a string b that represents a binary number and uses recursion
         to convert the number from binary to decimal.'''
      counter = -1    
      storage = 0    
      if b == 0:   
          return '0'
      elif b == 1:
          return '1'
      else:    
          if b[-1] == 1:
              counter += 1
              storage += 2**counter
              return storage + bin_to_dec(b[:-1])
          else:
              counter += 1
              return bin_to_dec(b[:-1])
  </code></pre>
  <p>So I am writing a function that converts binary numbers to decimal numbers but every time the function is called recursively the variables counter and storage are reset. I must use recursion and can't use anything I haven't learned yet such as map or key.</p>