How to compare lists

Rustom Mody rustompmody at gmail.com
Tue Sep 1 13:26:57 EDT 2015


On Tuesday, September 1, 2015 at 12:54:08 PM UTC+5:30, 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)

To add to what the others have said/asked:

Many times programmers want sets but they are programmed(!!) to think "Lists!"
This can be because for example
>>> [1,2,3] == [2,1,3]
False
>>> {1,2,3} == {2,1,3}
True
>>> [1,2,3,3] == [1,2,3]
False
>>> {1,2,3,3} == {1,2,3}
True
>>> list(set([1,2,1,3,4,4,]))
[1, 2, 3, 4]

[Though theres no guarantee of the order of the last (that I know) ]

ie you may prefer sets to lists when order and/or repetition dont signify

> 
> E.g

???



More information about the Python-list mailing list