How to check if contents of two lists is same in python?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi
--
Chapters
00:00 How To Check If Contents Of Two Lists Is Same In Python?
00:48 Accepted Answer Score 4
01:22 Thank you
--
Full question
https://stackoverflow.com/questions/4141...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #list
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi
--
Chapters
00:00 How To Check If Contents Of Two Lists Is Same In Python?
00:48 Accepted Answer Score 4
01:22 Thank you
--
Full question
https://stackoverflow.com/questions/4141...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #list
#avk47
ACCEPTED ANSWER
Score 4
I interpret your question as return true if the contents (but not necessarily order) of the lists are identical, otherwise return false. This can be solved by sorting both lists, then using the == for comparison. sorted() returns a list of integers in ascending order. This means that if the lists' contents are the same, sorted() returns identical lists.
def validation(list_1,list_2):
    return sorted(list_1) == sorted(list_2)
This passes all of your test cases. I might have misunderstood your question, please clarify if that's the case.