I want to create a function that performs a certain task only when a hex value indicates an upper or lower case letter, i.e., when the hex code is between 20 and 7A. Is there a way to make a statement in python that is logically equivalent to:
if a >= 20 and a <= 7A: perform stuff
? Do I just throw a 0x in front of it and magic happens?
yes ... you just throw a 0x and it becomes numeric ....
or int("7A",16) == 0x7A
0x20 <= a <= 0x7A
you can also chain comparison operators like this (which translates roughly to "is a between val1 and val2")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With