title: converting a binary number to a decimal number without using lists
body: <pre><code>def b_num(n): 
      
      result = 0
  
      str_n = str(n)
      
      for j in str_n:
          if j == '1':
              result = result + 2**str_n.index(j)
                 
      
      print(result)
                  
                     
                  
  b_num(11011011)
  </code></pre>
  <p>This is my code to convert a binary number to a decimal number. I have input the binary number <strong>11011011</strong>which is supposed to give me <strong>219</strong> as the output. But I am getting only 6. Where have I made the mistake?</p>