In [1]:
#This is my Binary Conversion Program!
def main():
    binaryInput = input("Enter a Binary Number ==> ")
    exponentValue = len(binaryInput)
    totalValue = 0
    #the if options in case something happens
    if exponentValue < 1: #If the exponentValue is less than 1, the program deletes the binaryInput, exponentValue, and totalValue
        del binaryInput
        del exponentValue
        del totalValue
        print("you pressed enter, you need a value to run")
        main() #uses the main function again if you just press enter
        
    for conversion in range(exponentValue):
        if binaryInput[conversion] == "0":
            actualValue = 0
        elif binaryInput[conversion] == "1":
            actualValue = 2
        else: #If you print a number other than 0 or 1, the program deletes the binary, expont, and total values 
            print("0 or 1 please")
            del binaryInput
            del exponentValue
            del totalValue
            main() #restarts main function again if you enter a number that's not 0 or 1
            
        trueValue = actualValue ** (exponentValue -1) #raises the value of actualValue to exponentValue -1
            
        if actualValue == 0 and exponentValue == 1: 
            trueValue = 0
            
        exponentValue -= 1 #this means that it is equal to exponent value - 1
        
        totalValue += trueValue
            #prints out the answer
    print("The Decimal Value of {} is {}".format(binaryInput,totalValue))
    #quit()
      
    
    
main()
Enter a Binary Number ==> 10111
The Decimal Value of 10111 is 23