Hello guys
I want to convert an integer to a hexadecimal string
examples
lets say i have an integer value 1 i want to convert it to 0001
integer value of 16 => 0010
245 =>00F5
and so on the string must have a length of 4 digits
my code is like this but i was wondering if there is an another way to do it
new_address=hex(new_address)[2:].upper()
if len(new_address)==3:
new_address="0"+new_address
elif len(new_address)==2:
new_address="00"+new_address
elif len(new_address)==1:
new_address="000"+new_address
print new_address