good, bad = [], [] for x in mylist: (bad, good)[x in goodvals].append(x) # good.append(x) if x in goodvals else bad.append(x) # for x in mylist: (good if isgood(x) else bad).append(x) # (good if x in goodvals else bad).append(x)