def last(seq, key=(lambda x: bool(x)), default=None, apply=(lambda x: x)):
    return next((apply(x) for x in reversed(seq) if key(x)), default)
def last(seq, key=(lambda x: bool(x)), default=None, apply=(lambda x: x)):
    return next((apply(x) for x in reversed(seq) if key(x)), default)