myinput = raw_input("Please enter a binary real number: ")<br>myinput = myinput.split(".")<br><br>binstr1 = myinput[0]<br>binstr2 = myinput[1]<br><br>decnum1 = 0<br>decnum2 = 0<br><br>for i in binstr1:<br>
decnum1 = decnum1 * 2 + int(i)<br><br>for k in binstr2:<br> decnum2 = decnum2 * 2 + int(k)<br><br><br><br>print "\nThe binary real number ", binstr1, ".", binstr2, " converts to ", decnum1,".",decnum2," in decimal."<br>
<br><br>that is what I have so far but I need to create a condition where I need only 10 sufficient numbers from the variable decnum2. I know I need something like<br>if len(decnum2) > 11:<br> decnum2 = decnum2[0:11]<br>
<br>but I keep getting unsubscriptable errors. I know it has to do with types but it's late and I just need some help. thank you in advance. - chris<br>