Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Compare a list to a integer

Tags:

python

hex

Ok, no i dont believe this is a repeat question of the other ones on here. Here is what i am trying to do (I am new to Python and self teaching so bear with me).

I have a set of data that is a length of 3. This set makes up a hex value i.e. 0,9,9f is really just the hex value 99f.

I want to take that data set and compare it to an integer that i have (2463). I know there is a decimal to hex converter but how do i combine the data set or split apart the integer value to be able to compare the two to make sure they are equal?

like image 868
ageoff Avatar asked Dec 15 '22 22:12

ageoff


1 Answers

Where your list is 3 elements containing '99f' - the following returns 2463

int(''.join(your_list), 16)
like image 168
Jon Clements Avatar answered Jan 01 '23 03:01

Jon Clements