I am writing a code that converts a user inputted hexadecimal (base 16) number to base 10, but I can't use any built-in python functions, so it looks like this:
def base16TO10(base16):
value = base16
hexadecimal = sum(int(c) * (16 ** i) for i, c in enumerate(value[::-1]))
print("Base 16 number:" , base16 , "is base 10 number:" , hexadecimal ,"\n")
I need to make it so that if the letters A, B, C, D, E, or F are inputted as part of a base 16 number, the function will recognize them as 10,11,12,13,14, and 15, respectively, and will convert the number to base 10. Thanks!