The hex Python function produce 0x0 for the 0 number: >>> hex(0) '0x0' But bytes.fromhexa only accept hexa with minimum of two digits: >>> bytes.fromhex(hex(0)[2:]) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: non-hexadecimal number found in fromhex() arg at position 1 >>> bytes.fromhex('00') b'\x00' Why bytes.fromhexa accept hexa from two digits and no with one digit ? Continue reading...