input: Write a function to convert binary numbers to decimal.
  assert binary_to_decimal(1010) == 10
  assert binary_to_decimal(1111) == 15
  assert binary_to_decimal(1001) == 9
  assert binary_to_decimal(0) == 0
output: def binary_to_decimal(binary):
      decimal = 0
      binary_str = str(binary)
      for i, digit in enumerate(reversed(binary_str)):
          decimal += int(digit) * (2 ** i)
      return decimal