which is the easiest way that i can convert binary number into a hexadecimal number using latest python3?
i tried to convert a binary to number into a hexadecimal using hex() function. but it runs into few errors.
The code that i tried -:
choice = input("Enter Your Binary Number: ")
def binaryToHex(num):
answer = hex(num)
return(num)
print(binaryToHex(choice))
error that i faced :
Traceback (most recent call last):
File "e:\#Programming\Python\Number System Converter 0.1V\test.py", line 83, in <module>
print(binaryToHex(choice))
File "e:\#Programming\Python\Number System Converter 0.1V\test.py", line 80, in binaryToHex
answer = hex(num)
TypeError: 'str' object cannot be interpreted as an integer
EXAMPLE-:
- 111 --> 7
- 1010101011 --> 2AB