Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created May 25, 2020 22:51
Show Gist options
  • Save hsleonis/a286089f43fcd3c8d5d7262be50ea079 to your computer and use it in GitHub Desktop.
Save hsleonis/a286089f43fcd3c8d5d7262be50ea079 to your computer and use it in GitHub Desktop.
Removes falsey values from a list.
def dropna(lst):
  return list(filter(None, lst))
dropna([0, 5, False, 3, '', None, 1, 'b', 'K', 78]) # [ 5, 3, 1, 'b', 'K', 78 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment