The best way to check if two lists have identical values
mrkafk at gmail.com
Thu Feb 25 15:43:53 CET 2010
On 2010-02-25 14:55, Arnaud Delobelle wrote:
> Your code checks if the two lists have the same length and the same
> elements, but not necessarily the same number of each elements. E.g.
> qips = [1, 1, 2]
> oldqips = [1, 2, 2]
> will return True
> If you want to check if each value has the same number of occurences,
> you can do
> return sorted(qips) == sorted(oldqips)
> assuming that all elements in the lists are comparable.
More information about the Python-list