2相同的函数给出单独的结果吗?蟒蛇

我一直在尝试制作将二进制数字转换为十进制和十六进制的脚本。我能够轻松地进行小数点后一位,但是一旦达到十六进制,我就会开始遇到麻烦。我注意到,每次测试运行时,该值始终会返回0。我决定尝试使用十进制转换器中完全相同的代码,以确保它不仅是错误的编码。该值仍然返回0。有人知道为什么吗? (我使用python 3.8.1)

def decimal_calculator(binary):
   decimal = 0
   for i in range(len(binary)):
      digit = binary.pop()
      if digit == '1':
         decimal = decimal + pow(2, I)
   print("The decimal value of the binary number is: ", decimal)
def h_calculator(binary):
   decimal = 0
   for i in range(len(binary)):
       digit = binary.pop()
       if digit == '1':
          decimal = decimal + pow(2, i)
print("The decimal value of the binary number is: ", decimal)
def main():
   binary = list(input("Input a binary number: "))
   decimal_calculator(binary)
   hex_calculator(binary)
main()

例如,如果我在输入位置输入以下代码,则该代码为:10010010,第一个响应为146,这是正确的,但第二个响应为0。我们将不胜感激。