Last active
October 4, 2018 14:44
-
-
Save jorgeas80/6110f31ede55f7708c4450a015b2be94 to your computer and use it in GitHub Desktop.
Python one-liner to show a comma-separated string of all the not None elements of a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import is_not | |
from functools import partial | |
fruits = ["apple", "banana", None, "pear", None, "peach", None, None, "grapes"] | |
# Prints: apple, banana, pear, peach, grapes | |
print(", ".join(filter(partial(is_not, None), fruits))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment