You are trying to parse strings as numbers in hexadecimal, where each string is two characters from h
. That means your string h
needs to be long enough to have content for each of the substrings.
For instance, if h
is '1234'
, then
h[0:2] == '12'
h[2:4] == '34'
h[4:6] == ''
Your code can parse '12'
and '34'
as numbers in hex, but it can’t parse ''
, so it would raise an exception.
solved ValueError: invalid literal for int() with base 16: ” [closed]