The best way to check if two lists have identical values
Daniel Stutzbach
daniel at stutzbachenterprises.com
Thu Feb 25 09:25:22 EST 2010
On Thu, Feb 25, 2010 at 7:30 AM, mk <mrkafk at gmail.com> wrote:
> There's a number of complications here, depending on definition of 'lists
> with identical values', like whether the same value can be repeated
> different number of times in two lists, or whether the order of values
> matters.
>
Order and repetitions matter:
list1 == list2
Repetition matters, order does not:
sorted(list1) == sorted(list2) # items must be comparable
Neither matters:
set(list1) == set(list2) # items must be hashable
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100225/cfb93e87/attachment-0001.html>
More information about the Python-list
mailing list