Aside from several ugly antipatterns, there’s one obvious mistake/typo: Take a good look at
if a > 0:
kb = int(str(byte)[a:b])
else:
kd = int(str(byte)[0:b])
Do you see now where your error comes from?
1
solved What is wrong with this programming? [closed]