def separate(func, seq):
    """
    Similar to the built-in filter() function, but returns two sequences with
    the (filtered in, filtered out) values.

    Examples:
        >>> separate(lambda x: x % 3, [1, 2, 3, 4, 5, 6])
        ([1, 2, 4, 5], [3, 6])

        Respect the type of input sequence just as the filter() function

        >>> separate(lambda x: x.islower(), 'FoobAR')
        ('oob', 'FAR')
    """
    func = bool if func is None else func
    L1, L2 = [], []
    for x in seq:
        (L1 if func(x) else L2).append(x)
    if isinstance(seq, str):
        return ''.join(L1), ''.join(L2)
    elif isinstance(seq, tuple):
        return tuple(L1), tuple(L2)
    else:
        return L1, L2
