result = filter(lambda y: y != 0, [x in betas and x for x in alphas]) result.sort()