I am trying to create a bunch of binary files that contain corresponding hex values
for i in range(2**8):
    file = open("test" + str(i) + ".bin", "wb")
    file.write(hex(i))
    file.close()
Unfortunately it appears that a text representation of my counter converted to hex is being written to the files instead of the actual hex values.  Can someone please correct this code?  I'm sure the problem is with hex(i)

hex(x)docs specifically say that it returns a string. docs.python.org/3/library/functions.html#hex But hex is a representation: do you want to write the binary representation of that hex string? Or the binary representation ofi?struct.pack