Removes from set1 any items which don't appear in set2 and returns the result.

def intersection (set1, set2):
    """ Removes from set1 any items which don't appear in set2 and returns the result.
    """
    assert is_iterable(set1)
    assert is_iterable(set2)
    result = []
    for v in set1:
        if v in set2:
            result.append (v)
    return result