Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make range in hexadecimal python?

Tags:

python

I want to make a range in python from variable a and variable b

a = 0x88
b = 0xff
for x range(a, b):
    print(x)

from my code the result like this 136, 137, 138, 139 ...

but I want the result of looping like this

88, 89, 8a, 8b, 8c, 8d, 8e, 8f, 90, 91 .... ff

please help me, thank you

like image 939
Zmx Atah Avatar asked Oct 18 '25 13:10

Zmx Atah


1 Answers

Use hex() function:

a = 0x88
b = 0xff
for x in range(a, b):
    print(hex(x))

results in:

0x88
0x89
0x8a
0x8b
0x8c
0x8d
0x8e
0x8f
0x90
0x91
0x92
0x93
0x94
...
like image 58
Hamza Avatar answered Oct 21 '25 04:10

Hamza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!