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


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

Sample Run 1:

Enter your binary number:111001


Sample Run 2:

Enter your binary number:1111111111000000110101



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


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