Skip to content
Code ReadingBinary to Decimal
Break the Code

Binary to Decimal

Write a text for which this function gives the wrong answer.
1def to_number(bits):
2 value = 0
3 for i in range(len(bits)):
4 if bits[i] == "1":
5 value += 2 ** i
6 return value