# convert a binary number to integer B = input("Enter a binary number as a series of 1's and 0's: ") I = 0 while B != '': I = I * 2 + (ord(B[0]) - ord('0')) B = B[1:]