Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active May 25, 2020 21:45
Show Gist options
  • Save hsleonis/089b21c2c1951b1c076c4e7747b7f9be to your computer and use it in GitHub Desktop.
Save hsleonis/089b21c2c1951b1c076c4e7747b7f9be to your computer and use it in GitHub Desktop.
Splits list values into two groups.
def split_list(lst, filter):
  return [
    [x for i, x in enumerate(lst) if filter[i] == True],
    [x for i, x in enumerate(lst) if filter[i] == False]
  ]
split_list(['beep', 'boop', 'foo', 'bar'], [True, True, False, True]) # [ ['beep', 'boop', 'bar'], ['foo'] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment