I'm trying to turn an alphanumeric string into a hexadecimal number.
The following code works as intended...
A = "f8g9dsf9s7ff7s9dfg98d9fg97s06s6df5"
B = int(A, 16)
When I try create the alphanumeric dynamically it breaks and doesn't get converted to hexadecimal number...
A = ''.join(random.choices(string.ascii_lowercase + string.digits, k=34))
B = int(A, 16)
Thanks for the help, extremely new to Python.
string.ascii_lowercaseis a string composed of the whole alphabet composed from 'a' to 'z' but only A..F are valid for hexadecimal which is base-16. Callingint()with non-A..F characters will raise a ValueError. Use string "abcdef" for the letters.Output: