Getting a type error

python

#1

Hi,
Here is my code for directly converting a binary number to a hexadecimal number. I input the binary number as a string. Then the binary string is formatted. I place leading zeroes to make
len(binaryString) a multiple of 4. I use the fact that grouping 4 digits of a binary number from the right produces a decimal value. Then you replace that decimal value with the corresponding hex digit. And repeat this process to obtain all the hexadecimal digits.

I got this error and I have no idea what I did wrong:

def main():
    binaryNumber = input("Enter a binary number: ")
    binaryNumber = formatBinaryNumber(binaryNumber)   # Add leading zeroes to binaryNumber to make the len(binaryNumber) % 4 = 0
    hexNumber = binaryToHex(binaryNumber)
    print(hexNumber)


def formatBinaryNumber(binaryNumber):
    length = len(binaryNumber)
    if length % 4 == 0:
        return binaryNumber
    else:
        return (4 - (length % 4)) * '0' + binaryNumber


def binaryToHex(binaryNumber):
    length = len(binaryNumber)
    hexNumber = ""
    for i in range(0, length // 4):
        hexDigit = determineHexDigit(binaryNumber, i)
        hexNumber = hexNumber + hexDigit

    return hexNumber


def determineHexDigit(binaryNumber, i):
    slice = binaryNumber[i, i + 4]
    sum = 0

    if slice[i] == '1':
        sum += 8
    if slice[i + 1] == '1':
        sum += 4
    if slice[i + 2] == '1':
        sum += 2
    if slice[i + 3] == '1':
        sum += 1

    if 0 <= sum <= 9:
        return str(sum)
    else:  # 10 <= sum <= 15
        return chr(ord('A') + sum - 10)


main()

#2

Never mind I see where I went wrong. I put , instead of :.