Apply function to list depending on values in another list This is probably a duplicate, but I don’t seem to find this specific case.