How to compare lists

jmp jeanmichel at sequans.com
Tue Sep 1 05:00:21 EDT 2015


On 09/01/2015 07:08 AM, Jahn wrote:
>
>
> 1.
> How can I save 256 lists, each list has 32 values( hexadecimal numbers)
> 2.
> How to compare the saved lists with another 256 lists ( that are read online and have the
> same structure as the list one)?
> ( the first list must be saved in the  previous step)
>
> E.g
>
>
> Thanks
>

Dumb down your problem to something simpler.

saving 2 lists of 2 numbers.

1/ for saving/loading the list, use pickle if *you* will do the saving 
*and* the loading (don't load from an untrusted file)

2/ To compare 2 lists, simply use the == operator

In [4]: [[1,2], [1,2]] == [[1,2], [1,3]]
Out[4]: False

In [5]: [[1,2], [1,2]] == [[1,2], [1,2]]
Out[5]: True

JM




More information about the Python-list mailing list