Compare two lists value-wise in Python [closed]

If you don’t care about the order of elements you can do this:

def compare(a, b):
    return 'matched' if sorted(a) == sorted(b) else 'unmatched'

a = [1,1,3,4]
b = [3,1,4,1]
print(compare(a, b))

>>> 'matched'

Browse More Popular Posts

Leave a Comment