I need to create a program where I input a six digit binary number, and for it to output the decimal equivalent. But I'm struggling to figure out how to match the input digits to their equivalent powers of 2 list.
So 100001 should grab the first item in my powers of 2 list - 32, and the last item, 1.
powersof2 = [32, 16, 8, 4, 2, 1]
e = []
i = str(input("Enter: "))
for a in powersof2:
for x in i:
if "0" in x:
continue
if "1" in x:
e.append(a)
print(e)
Obviously at the moment, it's just printing all of the powersof2 list, rather than individually because I can't figure out how to make it continue to the next item in powrsof2?