"def hex_to_decimal(num):\n    decimal = 0\n    for i in range(len(num)):\n        if num[i] == A:\n            decimal += 10 * (16 ** (len(num)-i-1))\n        elif num[i] == B:\n            decimal += 11 * (16 ** (len(num)-i-1))\n        elif num[i] == C:\n            decimal += 12 * (16 ** (len(num)-i-1))\n        elif num[i] == D:\n            decimal += 13 * (16 ** (len(num)-i-1))\n        elif num[i] == E:\n            decimal += 14 * (16 ** (len(num)-i-1))\n        elif num[i] == F:\n            decimal += 15 * (16 ** (len(num)-i-1))\n        else:\n            decimal += int(num[i]) * (16 ** (len(num)-i-1))\n    return decimal"
Write a function to convert a given hexadecimal number to its decimal equivalent.?