def main():
binaryInput =input("Enter a binary number ==> ")
exponentValue =len(binaryInput)
totalValue = 0
# ^ This is the starting command when we start our line of code, when we press start it will say,"Enter a
# binary number ==> ".
if exponentValue < 1:
del binaryInput
del exponentValue
del totalValue
print("All you did was press enter,I need a value to run")
main()
# ^ get rid of the binaryinput, exponentvalue, and total value. Then we print out "all you did was press enter,
#I need a value to run" Once we press enter without putting any number
for conversion in range(exponentValue):
print(binaryInput[conversion])
if binaryInput[conversion] == "0":
actualValue = 0
elif binaryInput[conversion] == "1":
actualValue = 2
else:
print("0 or 1 please")
del binaryInput
del exponentValue
del totalValue
main()
# ^ You can only type 0 or 1 for the code to work, if you type in any other thing other then 0 and 1 it will show
#"0 or 1 please" it will also delete the binaryInput, exponentValue, and totalValue .
#So for anyone using it, they will have to type 0 or 1 for the code to work
trueValue = actualValue **(exponentValue -1)
if actualValue == 0 and exponentValue == 1:
trueValue = 0
exponentValue -= 1
totalValue += trueValue
print("The decimal value of {} is {}".format(binaryInput,totalValue))
quit()
# ^ This is the final thing once you typed in your values, it will pop up with a text saying, "The decimal value of (Value)
# is (Value)". then after it gives you your final result it will end
main()