Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python filter None dictionary

d = dict(a = 1, b = None, c = 3)

filtered = dict(filter(lambda item: item[1] is not None, d.items()))

print(filtered)
{'a': 1, 'c': 3}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #filter #None #dictionary
ADD COMMENT
Topic
Name
9+6 =