Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95826

Re: How to compare lists

From jmp <jeanmichel@sequans.com>
Subject Re: How to compare lists
Date 2015-09-01 11:00 +0200
References <55E54F00.15583.2941C4EC@jana1972.centrum.cz>
Newsgroups comp.lang.python
Message-ID <mailman.42.1441098049.23514.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to compare  lists jmp <jeanmichel@sequans.com> - 2015-09-01 11:00 +0200

csiph-web