• Lambda solution

Question related to mission Non-unique Elements

 

This is my solution using a lambda funtion. I think that is a interesting way to solve the test

def checkio(data):
    data = filter(lambda x: unicode(x) if data.count(x) > 1 else None, data)
    return data

if __name__ == "__main__":
    assert isinstance(checkio([1]), list), "The result must be a list"
    assert checkio([1, 2, 3, 1, 3]) == [1, 3, 1, 3], "1st example"
    assert checkio([1, 2, 3, 4, 5]) == [], "2nd example"
    assert checkio([5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5], "3rd example"
    assert checkio([10, 9, 10, 10, 9, 8]) == [10, 9, 10, 10, 9], "4th example"