In [ ]:
#define main function 
def main():
    binaryInput = input("Enter random binary number ==> ")
    #exponentValue equals the len ,binary input
    exponentValue = len(binaryInput)
    #decimal value when your done
    totalValue = 0
    #deleting the values then adding a main()
    if exponentValue < 1:
        del binaryInput
        del exponentValue
        del totalValue
        print("you just only pressed eneter, give a value to run")
        main()
        #conversion is going to go through each item in conversion or each letter
    for conversion in range(exponentValue):
        print(conversion)
        print(binaryInput[conversion])
        if binaryInput[conversion]== "0":
            acutalValue = 0
        elif binaryInput[conversion] =="1":
            actualValue = 2
    else:
        #deletes the program then main() restarts the program
        print("enter 0 or 1")
        del binaryInput
        del exponentValue
        del totalValue
        #main() restars the program
        main()
        #0 to the power of 0 = 1
        #2 to the power of 0 = 1
        #1 to the power of 0 = 1
        #0 to the power of 1 = 0
        #any thing to the power of 0 = 1
        
        
        
        #allows you to get to the value of 0
        trueValue = actualValue ** (exponentValue -1)
       
    if actualValue == 0 and exponentValue == 1:
        trueValue = 0
        
    exponentValue -= 1 
    #this is the exact same format
    exponentValue = exponentValue -1
        #total value + true value = true value
    toalValue += trueValue
    print("The decimal value value of {} is {}".format(binaryInput,totalValue))
    quit()
main()
In [ ]: