I need to increment the hex value (CMD = "\xA0\x00\x00") by 32 in order to write to an i2c eeprom from a python script. I can't figure out how to increment this string in a loop.
I tried to implement it like this
increment =20
CMD = "\xA0\x00\x00"
for i in range(0,N):
command=CMD+str(increment)
increment+=20
#Code to write to the value goes here
I assumed it would increment in the order
"\xA0\x00\x00"
"\xA0\x00\x0020"
"\xA0\x00\x0040"
"\xA0\x00\x0060"
#onwards
But it didn't work. Any help would be appreciated!
EDIT :
This is what the output was when i tried to add str(20) to the command.
>>> WCMD = "\xA0\x00\x00"
>>> WCMD=WCMD+str(20)
>>> WCMD
'\xa0\x00\x0020'
>>>
>>> print(WCMD)
�20
>>> WCMD[0]
'\xa0'
>>> WCMD[1]
'\x00'
>>> WCMD[3]
'2'
>>> WCMD[4]
'0'
>>> WCMD
'\xa0\x00\x0020'
>>>