Help to solve this: it works on repl.it but not in python


#1

total = 0
exp = 0

binary = input(“Enter your binary number:”)

while len(binary) > 20:
binary = input (“Error”)

for i in range(5, -1, -1):
total += int(binary[i])*2**exp
exp+=1

Sample Run 1:

Enter your binary number:111001

57

Sample Run 2:

Enter your binary number:1111111111000000110101

Error
print(total)


#2

What do you mean that doesn’t work on Python? What is the error message you getting?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.