Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
The best way to check if two lists have identical values
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Arnaud Delobelle, post: 4033484"] 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. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
The best way to check if two lists have identical values
Top