I am having some difficulties in producing the correct code for a simple binary to decimal conversion program. The arithmetic I want to use is the doubling method - so if I wanted to get the decimal equivalent of 1001, I would start with multiplying 0 * 2 and adding the left most digit. I would then take the sum of 1 and multiply it by 2 and add the next digit to that product and so on and so forth until I come to an end sum of 9.<br>
<br>I seem to come up with something like this:<br><br>binnum = raw_input(&quot;Please enter a binary number:  &quot;)<br><br><br>for i in range(0, len(binum), 1):<br>    item = &quot;0&quot;<br>    if i &lt; len(binum) - 1:<br>
        item = binum[i + 1]<br>    <br>    binsum = binsum * int(item) * 2 + binsum + int(binum[i])<br><br><br>print &quot;\nThe binary number &quot;, binum, &quot; you entered converts to&quot;, binsum, &quot; in decimal.&quot;<br>
<br><br>I can&#39;t really figure out what is going wrong here. Please help me - this has been driving me insane.<br>